Solved

Lotus Designer - If field is modified, send email

Posted on 2011-02-28
9
537 Views
Last Modified: 2013-12-18
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!
0
Comment
Question by:SGCAdmin
  • 5
  • 4
9 Comments
 
LVL 22

Expert Comment

by:mbonaci
ID: 34997114
Here's the example:
http://www.experts-exchange.com/Q_26801145.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...
0
 
LVL 22

Expert Comment

by:mbonaci
ID: 34997178
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.
0
 
LVL 1

Author Comment

by:SGCAdmin
ID: 34997600
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 :-)
0
 
LVL 22

Expert Comment

by:mbonaci
ID: 34997744
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

0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 1

Author Comment

by:SGCAdmin
ID: 34998114
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
0
 
LVL 22

Accepted Solution

by:
mbonaci earned 250 total points
ID: 34998336
Yes, it's pretty easy (wasn't tested, so get back to me if some kind of error occurs):
Dim s As New NotesSession
Dim db As NotesDatabase
Dim newDoc As NotesDocument
Dim rtitem As NotesRichTextItem

If isDocSaved Then
	'doc was saved

	If source.document.ReplaceWithYourFieldNameYouWantToTrackChangesFor(0) <> fldValueOpen Then
		'field is changed - send reminder
		Set db = s.CurrentDatabase
		Set newDoc = New NotesDocument(db)
		Set rtitem = New NotesRichTextItem(newDoc, "Body")

		Call rtitem.AppendDocLink(source.document, source.document.SomeSignificantFieldLikeSubject(0))

		newDoc.Subject = "The document field changed"
		newDoc.SendTo = "Recipient e-mail" 'user array if you have multiple recipients
		'newDoc.SaveMessageOnSend = True 'uncomment this line if you want to save mail in your mail Sent folder

		newDoc.Send(False)
        End If
End If

Open in new window

0
 
LVL 1

Author Comment

by:SGCAdmin
ID: 34998560
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
0
 
LVL 22

Expert Comment

by:mbonaci
ID: 35005044
That code is supposed to replace the existing code in QueryClose (except first and last line - Sub QueryClose and End Sub)
0
 
LVL 1

Author Closing Comment

by:SGCAdmin
ID: 35008060
Perfect, thanks very much!

I appreciate the detailed steps :-)
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

  In today’s Arena we can’t imagine our lives without Internet as we are highly used to of it. If we consider our life style just for only 2 min we found that face to face communication is swapped by e-communication.  Every Where from Works place to…
Notes Document Link used by IBM Notes is a link file which aids in the sharing of links to documents in email and webpages. The posts describe the importance and steps to create a Lotus Notes NDL file in brief.
Migrating to Microsoft Office 365 is becoming increasingly popular for organizations both large and small. If you have made the leap to Microsoft’s cloud platform, you know that you will need to create a corporate email signature for your Office 365…
Many functions in Excel can make decisions. The most simple of these is the IF function: it returns a value depending on whether a condition you describe is true or false. Once you get the hang of using the IF function, you will find it easier to us…

895 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now