I’ve created a list of fields and I want to loop through the list to check the value in each field and, if the value is not correct, assign it a new value. This is for a form that is read in the Notes client (not the web). It gets executed during a button click - I am using the formula language.
I can get the code to either a) read the value stored in each field correctly, or b) write the value out to the field correctly, but not both.
If I build the list like so: listOfFIelds := statusField1 : statusField2 : statusField3;
… then I CAN read the value stored in the field: istOfFIelds[1] != “Approved”) will get the value stored in statusField1 and compare it to “Approved”
… but in this case I can NOT write the value out; @SetField(listOfFIelds[1] ; “Approved”) does not work - it seems to look up the value stored in statusField1 (say “Pending”) then tries (here is the problem) to find a field named “Pending” and assign the value “Approved” to that field.
If I build the list like so: listOfFIelds := “statusField1” : “statusField2” : “statusField3”;
… then I can NOT read the value stored in the field: istOfFIelds[1] != “Approved”) does what you expect - it compares the value “statusField1” to “Approved” and sees that they don’t match
… but in this case I CAN write the value out; @SetField(listOfFIelds[1] ; “Approved”) will properly assign the value “Approved” to the field named statusField1
Below is an example of how I am trying to this - it is quite a bit simpler than what I am really trying to achieve (which involves 3 separate array/lists.
listOfFIelds := “statusField1” : “statusField2” : “statusField3”;
REM { listOfFIelds := statusField1 : statusField2 : statusField3;};
n := 1;
@While(n <= @Elements(listOfFIelds);
@If(listOfFIelds[n] != "Approved";@SetField(listOfFIelds[n] ; "Approved");"");
n := n + 1
) ;
I could break down and abandon the idea of looping though the list/array of fields and do something like below, but that would be much messier.
@If(statusField1 != “Approved”;@SetField(statusField1 ; “Approved”);“”);
@If(statusField2 != “Approved”;@SetField(statusField2 ; “Approved”);“”);
@If(statusField3 != “Approved”;@SetField(statusField3 ; “Approved”);“”);
How can I use a list/array of fields and successfully read from and write to fields in the list?