Subject: PostSave not saving field value
The PostSave event is fine but you should use Lotusscript and write the change into the back end. Notesuidocument - called Source in the PostSave event - is the front end object. Each notesuidocument has a back end object that represents the data independent of the interface. (Interestingly the back end is available even before the document has been saved.) You cannot call notesuidocument.save here - because that would be a loop - but you can write the back end.
Sub Postsave(Source As Notesuidocument)
dim s as notessession
dim db as notesdatabase
dim doc as notesdocument
dim item as notesitem
dim agent as notesagent
set doc = Source.document
set item = doc.getfirstitem(“wAssignment”)
if item.contains(“0”) then
set s = new notessession
set db = s.currentdatabase
set agent = db.getagent(“Test”)
call agent.run
end if
’ ****************************************************************************************
’ This will cause Source to reload data from the back end. It’s a good
’ practice to call .refresh after doing this, such as if you have hide-when
’ formulas that depend on the value of wAssignment.
’ ****************************************************************************************
with doc
call .replaceitemvalue(“wAssignment”,“1”)
call .save(false,false)
end with
call Source.refresh
msgbox “On Save”, doc.getfirstitem(“wAssignment”).text
End sub
@If(@Contains(wAssignment; “0”);@Command([RunAgent]; “Test”); @Failure(“”));
FIELD wAssignment := “1”;
@All;
@Prompt([Ok]; “On Save”; wAssignment)