Function EN Version 1.90

@RecalculateNote

Database Note

Syntax

@RecalculateNote(NOTEHANDLE1;NOTEHANDLE2;FLAGS3);
@RecalculateNote(NOTEHANDLE1;NOTEHANDLE2;FLAGS3;CHANGEDFIELDSTEXTLIST6);
@RecalculateNote(NOTEHANDLE1;NOTEHANDLE2;FLAGS3;TLERRFIELDNAMES4;NLERRFIELDEVENTS5);
@RecalculateNote(NOTEHANDLE1;NOTEHANDLE2;FLAGS3;TLERRFIELDNAMES4;NLERRFIELDEVENTS5;CHANGEDFIELDSTEXTLIST6);

Description

NOTEHANDLE NOTEHANDLE1
Document on which the recalculation should be executed.

NOTEHANDLE NOTEHANDLE2
Form design document containing the formulas and fields.

NF FLAGS3
0 Report errors
1 Continue on errors

Return TEXTLIST TLERRFIELDNAMES4
FieldNames from fields where errors occured.
Note: This List may not contain every field name.

Return NUMBERLIST TLERRFIELDEVENTS5
Error event codes:
1=Default Value Formula Error
2=Translation Formula Error
3=Validation Formula Error
4=Computed Field Value Formula Error
5=Verify Datatype for Field Error
6=Save computed Formula Field Error

Return TEXTLIST CHANGEDFIELDSTEXTLIST6
FieldNames from changed fields.

Return:
0=OK no field modified
1=OK one (or more) field(s) modified
@ERROR = The recalculation could not be executed

The recalculation will execute:
1 Validate fields with default value formulas
2 Validate fields with translation formulas
3 Validate fields with validation formulas
4 Calulate values for computed fields

Example: @RecalculateNote(NOTEHANDLE1;NOTEHANDLE2;FLAGS3;TLERRFIELDNAMES4;NLERRFIELDEVENTS5;CHANGEDFIELDSTEXTLIST6)

SrcDBPath:="TEST\\TESTDB1.NSF";
DesignNoteFormName:="RecalcNote";
SearchFormula:="SELECT Form=\"RecalcNote\" & Field_Input1=\"Test 1\"";

SrcDBH:=@OpenDB(SrcDBPath);

DesignNoteType:=4; /*Form-Design*/

DesignNoteH:=@OpenDesignNote(SrcDBH;DesignNoteFormName;DesignNoteType;DesignNoteH);

IDList:=@ScanDB(SrcDBH;SearchFormula;@AnyAllDay;1);
FirstFoundID:=@GetListElement(IDList;1);

TargetDocH:=@OpenNoteByID(SrcDBH;FirstFoundID;TargetDocH);
/*Field_Input1[TargetDocH]:=Field_Input2[TargetDocH];*/
@PrtVStack("TargetDocH";1;2048);
Ret:=@RecalculateNote(TargetDocH;DesignNoteH;0;RetErrorFieldNames;RetErrorFieldEvents;RetChangedFields);
@LogReport(Ret;3);
@LogReport("RetErrorFieldNames :"+@Implode(RetErrorFieldNames;", ");3);
@LogReport("RetErrorFieldEvents:"+@Implode(@Text(RetErrorFieldEvents);", ");3);
@LogReport("RetChangedFields :"+@Implode(@Text(RetChangedFields);", ");3);
@PrtVStack("TargetDocH";1;2048);

TargetDocH:=@CloseNote(TargetDocH;1);

DesignNoteH:=@CloseNote(DesignNoteH;0); /*Do not save form!*/
SrcDBH:=@CloseDB(SrcDBH);

Note:
This @Function is executed using driectly the domino/notes-api-functions!
This @Function can be used to perform almost any kind of data manipulation. However, it must be taken into account that the individual formulas of "Computed" fields apparently may be executed multiple times.
Therefore, when deleting field contents, make sure that other field contents whose calculations depend on them are protected against repeated calculation after their first calculation, for example by using constructs such as @If(@IsAvailable(XXX);@Return(XXX);"").