I am trying to get a different email depending on which fields have changed on the document. Using “Case”. I am not well versed on script. But I am modifying existing code. So, far I only get one instance of the case
“The estimated date that comments on the 8-K relating to Santa Claus II are requested from the SEC Services Review Consultant has been changed in the Document Review Request system from 7/15/2004 to 7/16/2004.”
I should receive 3 separate cases
Here is my code below:
’ We are still in the logic for an existing poe, and it is being saved. All the status of the poe have now been determined,
' and all email telling either the Sec Reviewer or Assigners have been done
intFieldsChanged = -1
’ If gDoc.getItemValue( “SECAvailableEstCal”)( 0) <> gDocOrigPOE.GetItemValue( “SECAvailableEstCal”)( 0) Then
If gDoc.getItemValue( "SECAvailableEstCal")( 0) <> gDocOrigPOE.GetItemValue( "SECAvailableEstCal")( 0) And gDocOrigPOE.GetItemValue( "SECAvailableEstCal")( 0)<>"" Then
intFieldsChanged = intFieldsChanged + 1
Redim Preserve aryStrFieldsChanged( intFieldsChanged)
’ If gDocOrigPOE.getItemValue( “SECAvailableEstCal”)( 0) <> “” Then
aryStrFieldsChanged( intFieldsChanged) = "Est date available for SEC Review was: " & gDocOrigPOE.getItemValue( "SECAvailableEstCal")( 0) & _
" changed to: " & gDoc.getItemValue( "SECAvailableEstCal")( 0)
'Else
' aryStrFieldsChanged( intFieldsChanged) = "Est date available for SEC Review changed to: " & gDoc.getItemValue( "SECAvailableEstCal")( 0)
'End If
End If
If gDoc.getItemValue( "SECCommentEstCal")( 0) <> gDocOrigPoe.GetItemValue( "SECCommentEstCal")( 0) And gDocOrigPoe.GetItemValue( "SECCommentEstCal")( 0)<>"" Then
intFieldsChanged = intFieldsChanged + 1
Redim Preserve aryStrFieldsChanged( intFieldsChanged)
’ If gDocOrigPOE.getItemValue( “SECCommentEstCal”)( 0) <> “” Then
aryStrFieldsChanged( intFieldsChanged) = "Est date comments are requested from SEC Review was: " & gDocOrigPOE.getItemValue( "SECCommentEstCal")( 0) & _
" changed to: " & gDoc.getItemValue( "SECCommentEstCal")( 0)
gDoc.ReminderNext="" ' This is set to the next "Ensure Completed Timely" date; this gets cleared out when SECAvailableEstCal is changed as the next reminder is 42 days from the new SECAvailableEstCal date
’ Else
’ aryStrFieldsChanged( intFieldsChanged) = "Est date comments available for SEC Review changed to: " & gDoc.getItemValue( “SECCommentEstCal”)( 0)
’ End If
End If
' If gDoc.getItemValue( "SECAvailableEstCal")( 0) <> gDocOrigPOE.GetItemValue( "SECAvailableEstCal")( 0) Then
If gDoc.getItemValue( "EstFilingDateCal")( 0) <> gDocOrigPOE.GetItemValue( "EstFilingDateCal")( 0) And gDocOrigPOE.GetItemValue( "EstFilingDateCal")( 0)<>"" Then
intFieldsChanged = intFieldsChanged + 1
Redim Preserve aryStrFieldsChanged( intFieldsChanged)
’ If gDocOrigPOE.getItemValue( “SECAvailableEstCal”)( 0) <> “” Then
aryStrFieldsChanged( intFieldsChanged) = "Estimate filing date was: " & gDocOrigPOE.getItemValue( "EstFilingDateCal")( 0) & _
" changed to: " & gDoc.getItemValue( "EstFilingDateCal")( 0)
'Else
' aryStrFieldsChanged( intFieldsChanged) = "Est date available for SEC Review changed to: " & gDoc.getItemValue( "SECAvailableEstCal")( 0)
'End If
End If
If intFieldsChanged <> - 1 Then
Set itmEditHistory = gDoc.getFirstItem( "editHistory")
If gDoc.GetItemValue( "editHistory")( 0) = "" Then 'No Edit History ever
Call itmEditHistory.appendToTextList( Now & " " & gSession.commonUserName)
For intFieldsChangedLoop = 0 To intFieldsChanged
Call itmEditHistory.appendToTextList( aryStrFieldsChanged( intFieldsChangedLoop))
Next
Else
Redim aryStrEditHistory( Ubound( itmEditHistory.values) )
For intFieldsChangedLoop = 0 To Ubound( itmEditHistory.values)
aryStrEditHistory( intFieldsChangedLoop) = itmEditHistory.values( intFieldsChangedLoop)
Next
Call gDoc.ReplaceItemValue( "editHistory", "")
Call itmEditHistory.appendToTextList( Now & " " & gSession.commonUserName)
For intFieldsChangedLoop = 0 To intFieldsChanged
Call itmEditHistory.appendToTextList( aryStrFieldsChanged( intFieldsChangedLoop))
Next
For intFieldsChangedLoop = 0 To Ubound( aryStrEditHistory)
Call itmEditHistory.appendToTextList( aryStrEditHistory( intFieldsChangedLoop))
Next
End If
Call gUiDoc.RefreshHideFormulas 'To Show them the Edit History, if it was hidden
If gDoc.getItemValue( "secReviewer")( 0) <> "None" Then
Set docMail = New NotesDocument( gDb)
Call docMail.replaceItemValue( "Form", "Memo")
Call docMail.replaceItemvalue( "Subject", gStrEmailPrefix & "Questions 3 or 4 have been changed")
Call docMail.replaceItemValue( "sendTo", gDoc.getitemValue( "secReviewer")( 0))
Set itm = docMail.getFirstItem( "sendTo")
Forall values In gDoc.partners
If values <> "" Then
If itm.Contains( values) = False Then
Call itm.appendToTextList( values)
End If
End If
End Forall
Forall values In gDoc.managers
If values <> "" Then
If itm.Contains( values) = False Then
Call itm.appendToTextList( values)
End If
End If
End Forall
Forall values In gDoc.concurringPartners
If values <> "" Then
If itm.Contains( values) = False Then
Call itm.appendToTextList( values)
End If
End If
End Forall
If itm.Contains( gDoc.GetItemValue( "projectPartner")( 0)) = False Then
Call itm.appendToTextList( gDoc.GetItemValue( "projectPartner")( 0))
End If
If itm.Contains( gDoc.GetItemValue( "projectManager")( 0)) = False Then
Call itm.appendToTextList( gDoc.GetItemValue( "projectManager")( 0))
End If
Set rtMailBody = New NotesRichTextItem( docMail, "Body")
For intFieldsChangedLoop = 0 To intFieldsChanged
Select Case Left$( aryStrFieldsChanged( intFieldsChangedLoop), 10)
Case "Est date c"
If intFieldsChangedLoop = 1 Then
Call rtmailBody.AddNewline( 2)
End If
Call rtMailBody.appendText( "The estimated date that comments on the " & strDocType)
Call rtmailBody.AppendText( " relating to " & gDoc.getItemvalue( "client")( 0) &" are requested from the SEC Services Review Consultant has been changed in the Document Review Request system")
If gDocOrigPOE.getItemValue( "SECCommentEstCal")( 0) <> "" Then
Call rtmailBody.AppendText( " from " & gDocOrigPOE.getItemValue( "SECCommentEstCal")( 0))
End If
Call rtMailBody.AppendText( " to " & gDoc.getItemValue( "SECCommentEstCal")( 0) & ".")
Case "Est filing a"
If intFieldsChangedLoop = 2 Then
Call rtmailBody.AddNewline( 2)
End If
Call rtmailBody.AddNewline( 2)
Call rtMailBody.appendText( "The estimated date that the " & strDocType)
Call rtmailBody.AppendText( " relating to " & gDoc.getItemvalue( "client")( 0) &" will be available for SEC Services review has been changed in the Document Review Request system")
If gDocOrigPOE.getItemValue( "SECAvailableEstCal")( 0)<> "" Then
Call rtmailBody.AppendText( " from " & gDocOrigPOE.getItemValue( "SECAvailableEstCal")( 0))
End If
Call rtMailBody.AppendText( " to " & gDoc.getItemValue( "SECAvailableEstCal")( 0) & "." )
Case "Est filing d"
If intFieldsChangedLoop = 3 Then
Call rtmailBody.AddNewline( 2)
End If
Call rtmailBody.AddNewline( 2)
Call rtMailBody.appendText( "The estimated filing date " & strDocType)
Call rtmailBody.AppendText(" relating to " & gDoc.getItemvalue( "client")( 0) &" has been changed in the Document Review Request system")
If gDocOrigPOE.getItemValue( "EstFilingDateCal")( 0) <> "" Then
Call rtmailBody.AppendText( " from " & gDocOrigPOE.getItemValue( "EstFilingDateCal")( 0))
End If
Call rtMailBody.AppendText( " to " & gDoc.getItemValue( "EstFilingDateCal")( 0) & ".")
End Select
Next
Call rtmailBody.AddNewline( 2)
Call rtMailBody.AppendText( "Link to Document Review Request Document ===> ")
Call rtMailBody.AppendDocLink( gDoc, gDoc.getItemvalue( "client")( 0))
strEMailType="POE SEC Reviewers (5)"
Call docMail.Send( False)
End If
End If
End If
End Select