Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Lotus Designer - If field is modified, send email

Posted on 2011-02-28
9
Medium Priority
?
545 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
Technology Partners: 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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

Problem "Can you help me recover my changes?  I double-clicked the attachment, made changes, and then hit Save before closing it.  But when I try to re-open it, my changes are missing!"    Solution This solution opens the Outlook Secure Temp Fold…
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.
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…
This lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …

609 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