Automatic send of a note with a doc link and subject text when a user changes a field

Dear expert,

How can I automatically have a note sent to a coded user that include a doc link to the form being edited with predetermined subject text filled in when a user changes a field in the form?

Thanks, Paul

Subject: compare values on save, use @mailsend option [includedoclink]

I wouldn’t do this the moment the field is changed - users sometimes accidentally change a field value - but instead on the save of the document. You can easily do it in formula, if you have a field in which you save the old value of the field in question.

Put something like this in the querysave on the document:

oldvalue := nameofoldvaluefield ;

newvalue := nameoffield ;

@if(oldvalue != newvalue;

@MailSend(sendto;copyto;“”;subject of message;comments + @NewLine;“”;[IncludeDoclink])) ;

0);

@setfield(“nameofoldvaluefield”; newvalue)

Subject: Thanks

Hi Maria, this sounds good. I’ll give it a try.

Thanks so much, Paul

Subject: Having difficulty saveing old and new data

Maria, I am not having luck saving the original and new data from the field. Can you check the example code syntax?

Shouldn’t I just need to save the original value of the variable and compare it to the current value? I couldn’t make this work either.

Thanks again, Paul

Subject: save original value prior to using querysave

The original value needs to be saved into some OTHER field, and the document saved, prior to the querysave running the code I provided. So, you might need to run an agent to update the existing documents by copying their existing field data into the “hidden field where you’re saving the value to compare”.

Subject: Worked it out - Thanks

Maria, FYI, I was able to make this work by using the following code in “OnChange” of the variable I am monitoring. Then testing for “Changed” in the document “QuerySave”

Sub Onchange(Source As Field)

Dim session As New NotesSession

Dim ws As New NotesUIWorkspace

Dim uidoc As NotesUIDocument

Set uidoc = ws.CurrentDocument

Call uidoc.FieldSetText("AutoStpPlt1Changed", "Changed")	

End Sub

Thanks for all your help, Paul