?
Solved

Lotus Designer - If field is modified, send email

Posted on 2011-02-28
9
Medium Priority
?
544 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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
 
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 1000 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

Want to be a Web Developer? Get Certified Today!

Enroll in the Certified Web Development Professional course package to learn HTML, Javascript, and PHP. Build a solid foundation to work toward your dream job!

Question has a verified solution.

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

For users on the Lotus Notes 8 Standard client, this article provides information on checking the Java Heap size and adjusting it to half of your system RAM in attempt to get the Lotus Notes 8.x Standard client to run faster.  I've had to exercise t…
You’ve got a lotus Domino web server, and you have been told that “leverage browser caching” is a must do. This means that we have to tell the browser everywhere in the web to use cache. In other words, we set (and send) an expiration date in the HT…
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…

800 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