Link to home
Start Free TrialLog in
Avatar of SGCAdmin
SGCAdmin

asked on

Lotus Designer - If field is modified, send email

Hi there,

Im trying to create a formula that would send an email anytime a particular field was modified in a form.  I would prefer if the email was sent when the save and close button is pushed so if the user changes his mind, the person wouldnt receive the email 2+ times.

Thanks!
Avatar of mbonaci
mbonaci
Flag of Croatia image

Here's the example:
https://www.experts-exchange.com/questions/26801145/Puzzled-on-computed-field-not-refreshing.html

The idea is to check at QueryClose whether the doc was saved.
If yes - the action is performed, which is in your case mail send.

If you need further explanation...
To clarify:
 1 - store field value in a global variable called fldValueOpen in your form's PostOpen event
 2 - set global variable isDocSaved to True in the PostSave event (which will obviously occur only after the doc is saved)
 3 - in the QueryClose event first check whether the doc was saved
 4 - if yes - then we check whether the current field value is different from fldValueOpen (was field value changed)
 5 - if yes - send mail

3: we check whether doc was saved because, at QueryClose, field could've been changed (so that fldValueOpen check would return True), but user can choose to discard changes and we don't want to send e-mail in this case.
Avatar of SGCAdmin
SGCAdmin

ASKER

Hi MBonaci,

Thanks for the quick response.  I'm not seeing anything on how to use the variable "fldvalueopen".  I only have basic design/programming skills, hoping to get a little more detail on this as well as the rest of the steps.  

Thanks again :-)
OK,
1. Open your form in Designer
2. In the code/form events section Go to Globals > Declarations
3. Place this code there:
Dim fldValueOpen As String
Dim isDocSaved As Boolean

Open in new window

4. Go to PostOpen form event and place this code inside the Sub:
fldValueOpen = source.document.ReplaceWithYourFieldNameYouWantToTrackChangesFor(0)

Open in new window

5. Go to form's PostSave event and place this code inside the Sub:
isDocSaved = True

Open in new window

6. Go To QueryClose event and place this code inside the Sub:

If isDocSaved Then
	'doc was saved

	If source.document.ReplaceWithYourFieldNameYouWantToTrackChangesFor(0) <> fldValueOpen Then
		'field is changed
		'for demonstration purposes we'll send current document (change this with standard memo if you want)
		Call source.document.send(True, "Recipient's e-mail") 'we're sending the form with document (don't do this in production environment)

	End If
End If

Open in new window

Thats great, works perfectly :-)

The email itself sends the form itself in the body of the email.  Is there a way to just send the doc link to the form itself?

Thanks
ASKER CERTIFIED SOLUTION
Avatar of mbonaci
mbonaci
Flag of Croatia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
I get an error "3: Illigal executable code in Declarations"
for this line "Dim s As New NotesSession"

The other Dim lines are just fine
That code is supposed to replace the existing code in QueryClose (except first and last line - Sub QueryClose and End Sub)
Perfect, thanks very much!

I appreciate the detailed steps :-)