Triggering a computed field

I am trying to automate the process of request form creation, but I’ve hit a roadblock. I am successfully taking an XML file as the input and using the NotesSAXParser and NotesDXLImporter to get the data into the Lotus Notes form…no issues here. However, I am not able to populate the request number field for each of the new forms, which is a computed field on the form. To be more specific, there is a hidden, computed field (inum), which uses a formula to get the last number used and adds one to it. Upon saving the form, the number in inum is appended to the year, a hypen and any necessary zeros to create the request number, which is stored in the request number field (also computed) on the form. Is there a way to “trigger” these computed fields to work in conjunction with importing the the XML file? I’m also open to suggestions on how to change the form so long as it will work when creating the forms automatically or when a user goes into the database and creates a form manually.

Subject: Triggering a computed field

I don’t see any code sample so I will assume you are using LotusScript and backend classes. Likely all you need is a ComputeWithForm.

Subject: RE: Triggering a computed field

Sorry…yes I am using LotusScript. The SAX agent opens the XML file as a NotesStream object and submits it to a SAX parser which reformats the data as DXL and then sends it to a DXL importer.

Subject: Triggering a computed field

Ok…I’m still not having any luck using the ComputeWithForm. Below are the formulas in the hidden/computed field (inum) and the Save Action which then populates the visible Trn_Num field. Any help/advice would be appreciated.

This if for inum (Shared Field):

year:=@Year(@Today);

col:=@DbLookup(“”:“Nocache”; “”; “(Numbers)”;@Text(year);2);

first:=@If(@IsError(col)|col=“”;“0”;@Text(@Subset(col;1)));

@If(@IsNewDoc;@Text(@TextToNumber(first) + 1); inum)

This if for the Save action:

FIELD Trn_Num:=Trn_Num;

@SetField(“Trn_Num”;@If(Trn_Num=“”;@Text(@Year(@Today))+“-”+@If(@Length(inum)=1;“0000” + inum; @If(@Length(inum)=2;“000” + inum; @If(@Length(inum)=3;“00”+inum;@If(@Length(inum)=4;“0” + inum; inum))));Trn_Num;

@Command([FileSave])