Solved

Lotus Designer - If field is modified, send email

Posted on 2011-02-28
9
536 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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

 
LVL 1

Author Comment

by:SGCAdmin
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
Perfect, thanks very much!

I appreciate the detailed steps :-)
0

Featured Post

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Suggested Solutions

I thought it will be a good idea to make a post as it will help in case someone else faces these issues. I trust this gives an idea how each entry in Notes.ini can mean a lot for the Domino Server to be functioning properly. This article discusses t…
Article by: Rob
Notes 8.5 Archiving Steps and Tips This article covers setting up a Notes archive, and helps understand some of the menu choices making setting up and maintaining a Notes archive file easier.
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

771 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

10 Experts available now in Live!

Get 1:1 Help Now