Jeremy WH Ang 11.May.12 01:38 AM a Web browser Notes ClientAll ReleasesAll Platforms
Any idea why this script is crashing? Is it to do with arrayapend or appendtotext list? I am running 8.5.3fp1.
Sub IApproveDealerReview
Dim ws As New NotesUIWorkspace
Dim session As New NotesSession
Dim db As NotesDatabase
Dim continue As Variant
Dim uidoc As NotesUIDocument
Dim cdoc As NotesDocument
Dim dialog As NotesDocument
Dim user As String
Dim lview As NotesView
Dim jcomments As NotesItem
Dim bdevmgr As NotesDocument
Dim salesmgr As NotesDocument
Dim gmmc As NotesDocument
Dim nbdevmgr As NotesName
Dim nsalesmgr As NotesName
Dim gmmcname As NotesName
Dim jnextapprover As NotesItem
Dim jarray As Variant
Dim jarray2 As Variant
Dim jarray3 As Variant
Dim jcount As Integer
Dim jsubject As String
Dim jbody As String
Dim uarray As Variant
Dim juserexists As String
Dim gmnotify As String
Set db = session.currentDatabase
Set uidoc=ws.CurrentDocument
Set cdoc=uidoc.Document
Set dialog = db.CreateDocument
Set lview=db.GetView("LookupKeyword")
Set salesmgr=lview.GetDocumentByKey("Authority~NationalSalesDirDevMgr")
Set bdevmgr=lview.GetDocumentByKey("Authority~BDevMgr")
Set gmmc=lview.GetDocumentByKey("Authority~GMMC")
Set nbdevmgr=session.CreateName(bdevmgr.Values(0))
Set nsalesmgr=session.CreateName(salesmgr.Values(0))
Set gmmcname=session.CreateName(gmmc.Values(0))
continue=True
continue = ws.DialogBox("ApprovalDialog",True, True, False, False, False, False,"Approval Process",dialog, True)
user=session.Commonusername
jsubject="Dealer review approval required for "+ cdoc.DealershipName(0)
jbody="Dealership review required for your approval."
uarray=cdoc.NextApprover
ForAll y In uarray
If user=y Then
juserexists="Yes"
End If
End ForAll
If juserexists="Yes" Then
uidoc.Editmode=True
If user=CStr(cdoc.RegionalManager2(0)) then
If cdoc.RenewOptionsDate4(0)="" Then
Call cdoc.ReplaceItemValue("RenewOptions7",dialog.RenewOptions(0))
Call cdoc.ReplaceItemValue("RenewOptions8",dialog.RenewOptionsYear(0))
Call cdoc.ReplaceItemValue("RenewOptionsDate4",Today)
Set jcomments=cdoc.GetFirstItem("comments")
Call jcomments.AppendToTextList(user+" ("+Today+")"+" - "+dialog.comments(0))
Call cdoc.ReplaceItemValue("NextApprover",nbdevmgr.Common)
Set jnextapprover=cdoc.GetFirstItem("NextApprover")
Call jnextapprover.AppendToTextList(nsalesmgr.Common)
Call JMailMemoVariant(cdoc.GetItemValue("AuthBDevMgr"),jsubject,jbody,cdoc)
Call JMailMemoVariant(cdoc.GetItemValue("AuthNatSalesDirDevMgr"),jsubject,jbody,cdoc)
End if
End If 'regionalmgr
If user=CStr(cdoc.AuthBDevMgr(0)) Then
If cdoc.RenewOptionsDate1(0)="" Then
' uidoc.EditMode=True
Call cdoc.ReplaceItemValue("RenewOptions4",dialog.RenewOptions(0))
Call cdoc.ReplaceItemValue("RenewOptions1",dialog.RenewOptionsYear(0))
Call cdoc.ReplaceItemValue("RenewOptionsDate1",Today)
Set jcomments=cdoc.GetFirstItem("comments")
Call jcomments.AppendToTextList(user+" ("+Today+")"+" - "+dialog.comments(0))
jarray=cdoc.NextApprover
jarray=arrayreplace(jarray,user,"")
cdoc.NextApprover=FullTrim(jarray)
'JA Check if GM exists, appends
If cdoc.FinalApproval(0)<>"Yes" Then
ForAll J In jarray
If J<>gmmcname.Common Then
jarray=ArrayAppend(jarray,gmmcname.Common)
If cdoc.RenewOptionsDate2(0)="" Then
Call JMailMemo(cdoc.GetItemValue("AuthGMMC"),jsubject,jbody,cdoc)
End If
end If
End ForAll
End if 'finalapproval
End If
End If 'Business Development Mgr
If user=CStr(cdoc.AuthNatSalesDirDevMgr(0)) Then
If cdoc.RenewOptionsDate2(0)="" Then
' uidoc.EditMode=True
If cdoc.FinalApproval(0)<>"Yes" Then
ForAll J1 In jarray2
If J1<>gmmcname.Common Then
jarray=ArrayAppend(jarray2,gmmcname.Common)
If cdoc.RenewOptionsDate1(0)="" Then
Call JMailMemo(cdoc.GetItemValue("AuthGMMC"),jsubject,jbody,cdoc)
End If
End If
End ForAll
End If 'finalapproval
End If
End If 'National Sales manager
If user=CStr(cdoc.AuthGMMC(0)) Then
If cdoc.RenewOptionsDate3(0)="" Then
' uidoc.EditMode=True