Modify script to send an email when a field contains a certain value

5 pts.
Tags:
Lotus Designer
Lotus Notes 7
LotusScript
I have a form that is filled out and it emails a group and a single person notifying them of a returned item. I would like to modify the script to notify a third party if a field contains a certain value. Sub Querysave(Source As Notesuidocument, Continue As Variant) Dim session As New NotesSession Dim db As NotesDatabase Dim doc As NotesDocument Dim mdoc As NotesDocument Dim rtitem As NotesRichTextItem Dim sendTo(1 To 4) As String Set db = session.CurrentDatabase Set doc = Source.Document 'If doc.OrderStatus(0) = "Not Completed" Then Exit Sub Set mdoc = db.CreateDocument Set rtitem = New NotesRichTextItem(mdoc, "Body" ) sendTo(1) = "Return Notify" sendTo(2) = Doc.Salesman(0) sendTo(3) = "Repair Notify" mdoc.SendTo = sendTo mdoc.Form = "Memo" mdoc.SaveMessageOnSend = False If doc.IsNewNote Then mdoc.Subject = "New Return to Warehouse form submitted for " + doc.ClientName(0) Call rtitem.AppendText("New Return to Warehouse form for " & forStr & " to " & doc.FromStore(0) & ". Entered by " & doc.CreatedBy(0) & ".") Call rtitem.AddNewLine(1) Call rtitem.AppendText("Please refer to the new document in the Return to Warehouse database using the DocLink below.") Call rtitem.AddNewLine(2) Call rtitem.AppendDocLink( doc, "New Return" ) Call mdoc.Send(False) Else mdoc.Subject = "Updated Return to Warehouse form for " + Doc.ClientName(0) Call rtitem.AppendText("The Return to Warehouse form for " & forStr & " to " & doc.FromStore(0) &  " has been updated by " & doc.UpdatedBy(0) & ".") Call rtitem.AddNewLine(1) Call rtitem.AppendText("Please refer to the updated document in the MReturn to Warehouse database using the DocLink below.") Call rtitem.AddNewLine(2) Call rtitem.AppendDocLink( doc, "Updated Return" ) Call mdoc.Send(False) End If End Sub I would only like email the  "Repair Notify " group if a the dRes field on the form has a value of DEF Thank You, Matt

Software/Hardware used:
Domino Designer 7, Lotus Notes 7

Answer Wiki

Thanks. We'll let you know when a new response is added.

Not sure if you want to only send mail to Repair Notify (and no one else) if it meets your conditions, or if you only want to include Repair Notify in the mailing (along with the others) if it meets your conditions.  If it’s the latter then this should work:

Take the line that says

sendTo(3) = “Repair Notify”

and put this before it

If doc.dRes( 0 ) = “DEF” Then

and put this after it (thereby wrapping it)

End If

 

If it’s the former, then change these three lines

sendTo(1) = “Return Notify”
sendTo(2) = Doc.Salesman(0)
sendTo(3) = “Repair Notify”

to

If doc.dRes( 0 ) = “DEF” Then

sendTo(1) = “Repair Notify”

Else

sendTo(1) = “Return Notify”
sendTo(2) = Doc.Salesman(0)
sendTo(3) = “Repair Notify”

End If

 

Discuss This Question:  

 
There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to:

To follow this tag...

There was an error processing your information. Please try again later.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Thanks! We'll email you when relevant content is added and updated.

Following