Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

Troubleshooting
Research
Professional Opinions
Ask a Question
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE

troubleshooting Question

LotusScript needs adjusting (sending mail)

Avatar of AliciaVee
AliciaVee asked on
Lotus IBM
17 Comments1 Solution658 ViewsLast Modified:
Experts,

A form will track issues and "sometimes" it will be helpful for specific users to receive an alert when the document is submitted.  I have a field SendNotify that is a yes or no value and if this is Yes -- then another field is displayed that provides the ability for users to select names from the address book, otherwise, this field (NotifyGroup) is hidden.

Now, I had this script working earlier today (leveraged from another application I built) but when I changed it to affect only new documents, it stopped working.  Probably have the Ifs and End Ifs in the wrong place -- or some other minor issue, but I've been trying to figure it out and I think I'm getting farther from the solution.

This is what I'd like the script to do:

If SendNotify = Yes, then send an alert -- but there are two versions based on what the status is.  Bottom line, for each document, there will always be two alerts sent, one for when the document is first created (RptStatus = Open and IsNewDoc) and then one for when the log is closed (RptStatus = Closed).  If the author makes changes to the document, after it is saved once -- I don't want alerts going, only when the status changes to closed (hence IsNewNote)

If SendNotify = No -- then this alert should not run at all -- it should be ignored.  I have ithe code in the PostSave event -- this is a client only appliccaiton.  Please help!  Thanks in advance.

AliciaV

============================

Sub Postsave(Source As Notesuidocument)
      
      Dim workspace As New NotesUIWorkspace
      Dim currentdoc As NotesDocument
      Dim dbase As NotesDatabase
      Dim Session As New NotesSession
      Dim docStatus As String
      Dim newDoc As NotesDocument
      Dim rtitem As NotesRichTextItem
      Set currentdoc = source.Document
      Source.AutoReload = False
      Set dbase = session.CurrentDatabase
      
      If currentdoc.SendNotify(0) = "Yes" Then
            
            docStatus =currentdoc.RptStatus(0)
            
            If docStatus ="Open" And currentdoc.IsNewNote  Then
                  Set newDoc = New NotesDocument( dbase )
                  Set rtitem = New NotesRichTextItem( newDoc, "Body" )
                  newdoc.Form= "Memo"
                  
                  If docStatus ="Open" Then
                        newdoc.SendTo= currentdoc.NotifyGroup
                        newdoc.Subject= "New DEM Online Log Report - Priority: " & currentdoc.LogPriority(0)
                        
                        Call rtitem.AppendText("This is an automated alert from the DEM Online Resource database")
                        Call rtitem.AddNewLine(2)
                        Call rtitem.AppendText("A New DEM Online Log Report has been created by " & currentdoc.dspDocAuthorDefault(0))
                        Call rtitem.AddNewLine(2)
                        Call rtitem.AppendText("Log Priority: " & currentdoc.LogPriority(0))
                        Call rtitem.AddNewLine(1)
                        Call rtitem.AppendText("Log Type: " & currentdoc.RptClassification(0))
                        Call rtitem.AddNewLine(1)
                        Call rtitem.AppendText("Support Contact Name: " & currentdoc.dspContactName(0))
                        Call rtitem.AddNewLine(2)
                        Call rtitem.AppendText("Information Reported: " & currentdoc.RptInfo(0))
                        Call rtitem.AddNewLine(2)
                        Call rtitem.AppendText("Click here to go to the document --->  ")
                        Call rtitem.AppendDocLink( currentdoc, "Log Report" )
                  Else
                        
                        If docStatus ="Closed" Then
                              
                              newdoc.SendTo= currentdoc.NotifyGroup
                              newdoc.Subject= "DEM Online Log Report Closed: " & currentdoc.RptInfo(0)
                              
                              Call rtitem.AppendText("This is an automated alert from the DEM Online Resource database")
                              Call rtitem.AddNewLine(2)
                              Call rtitem.AppendText("The following DEM Online Log Report has been closed: ")
                              Call rtitem.AddNewLine(2)
                              Call rtitem.AppendText("Log Priority: " & currentdoc.LogPriority(0))
                              Call rtitem.AddNewLine(1)
                              Call rtitem.AppendText("Log Type: " & currentdoc.RptClassification(0))
                              Call rtitem.AddNewLine(1)
                              Call rtitem.AppendText("Support Contact Name: " & currentdoc.RptContactName(0))
                              Call rtitem.AddNewLine(1)
                              Call rtitem.AppendText("Information Reported: " & currentdoc.RptInfo(0))
                              Call rtitem.AddNewLine(2)
                              Call rtitem.AppendText("Solution Description: " & currentdoc.RptSolution(0))
                              Call rtitem.AddNewLine(1)
                              Call rtitem.AppendText("To view additional information for this Log Report, click here ----> ")
                              Call rtitem.AppendDocLink( currentdoc, "Closed Log Report" )
                        End If
                        Call newDoc.Send( False )                              
                  End If
            End If             
      End If
      
End Sub
ASKER CERTIFIED SOLUTION
Avatar of marilyng
marilyng

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Commented:
This problem has been solved!
Unlock 1 Answer and 17 Comments.
See Answers