I have created an Action for whenever someone click on the button it will Revise the document and replace fields with different values. All code is behind the action is working, then only thing is when I save the doc, and come back in the If Statement I have at the bottom isn’t saving. It runs and works fine once when I click on the button, but it’s not saving, and the rest of the code is. Is there something else I need to add after my If Statement to get it save?!? Please advice Below is the code:
Sub Click(Source As Button)
On Error Goto ERRORHANDLING
Dim session As New NotesSession
Dim db As NotesDatabase
Dim doc, docA, docB As notesdocument
Dim view As NotesView
Dim collection As NotesDocumentCollection
Dim answer As Integer
Dim Title As String
Dim Author As String
Dim CheckOutComments As Variant
Set ws = New NotesUIWorkspace
Set session = New NotesSession
Set db = session.CurrentDatabase
Set collection = db.UnprocessedDocuments
For i = 1 To collection.Count
Set docB = collection.GetNthDocument( i )
Title = docB.Title(0)
Next
continue = "False"
Set view = db.getview("ReviseCheck")
Set docA = view.GetDocumentByKey( Title, True )
If Not docA Is Nothing Then
Author = docA.PolicyAuthor(0)
Messagebox ("This policy is being revised by " & Author &". " & "Multiple versions cannot be made to the same policy.")
Exit Sub
End If
Set view = db.getview("PeoplePolicyOwner")
Set doc = view.getfirstdocument
continue = "False"
user = session.CommonUserName
Do While Not (doc Is Nothing)
If user = doc.keyword(0) Then
continue = "True"
End If
Set doc = view.getnextdocument(doc)
Loop
If continue = "False" Then
Messagebox "You are not listed as a Policy Owner. Please contact Jean Liebetreu to be added."
Exit Sub
End If
Set view = db.getview("PeoplePolicyAuthor")
Set doc = view.getfirstdocument
continue = "False"
user = session.CommonUserName
Do While Not (doc Is Nothing)
If user = doc.getitemvalue("keyword")(0) Then
continue = "True"
End If
Set doc = view.getnextdocument(doc)
Loop
Set view=Nothing
Set doc=Nothing
If continue = "False" Then
Messagebox "You are not listed as a Policy Author. Please contact Jean Liebetreu to be added."
Exit Sub
End If
answer% = Messagebox(|You are revising a policy/risk alert.
Are you ready to continue?|, 36,“Revising a Policy/Risk Alert”)
If answer% = 7 Then
Exit Sub
End If
For i = 1 To collection.Count
Set docA = collection.GetNthDocument( i )
Set docB = db.CreateDocument
Call docA.CopyAllItems( docB, True )
Set item = docB.replaceitemvalue("Status","Revising")
Set item = docB.replaceitemvalue("Form","Policy")
Set item = docB.replaceitemvalue("PolicyReleaseCommentsHistory","")
Set item = docB.replaceitemvalue("CPCComments","")
Set item = docB.replaceitemvalue("CPCNeeded","")
Set item = docB.replaceitemvalue("ChangeType","TBD")
Set item = docb.replaceitemvalue("Comments","")
Set item = docB.replaceitemvalue("NameQAReview","")
Set item = docB.replaceitemvalue("InitialLoad","No")
Set item = docB.replaceitemvalue("PolicyAuthor",session.commonusername)
Set item = docB.replaceitemvalue("EditHistory","Created by " & session.commonusername & " " & Date)
Set item = docB.replaceitemvalue("CreatedBy","Created by " & session.commonusername & " on " & Date)
Set item = docB.replaceitemvalue("AuthorCheckout",session.commonusername)
Set item = docB.replaceitemvalue("AuthorPolicyOwner",session.commonusername)
Set item = docB.replaceitemvalue("AuthorCPC",session.commonusername)
Set item = docB.replaceitemvalue("ReaderCheckout",session.commonusername)
Set item = docB.replaceitemvalue("Release","TBD")
Set item = docB.ReplaceItemValue("ChangeHistoryHistory", docB.CommentsHistory(0) & docB.ChangeHistoryHistory(0))
Set item = docB.replaceitemvalue("Changehistory","")
Set item = docB.replaceitemvalue("CommentsHistory","")
Set item =docB.ReplaceItemValue("OwnerNotified","No")
’ Set item = docB.ReplaceItemValue(“RevisionMarkedOther”,“”)
If Len(doca.GetItemValue("ChangeHistoryHistory")(0)) = 0 Then
Call docb.ReplaceItemValue("ChangeHistoryHistory", doca.GetItemValue("Comments")(0))
Else
Call docb.ReplaceItemValue("ChangeHistoryHistory", doca.GetItemValue("Comments")(0) & Chr(10) & doca.GetItemValue("ChangeHistoryHistory")(0))
End If
Set item = docb.ReplaceItemValue("Comments","")
Call docA.save(True,True)
Next
Set uidoc=ws.EditDocument(True,docB)
Call uidoc.refresh
Exit Sub
ErrorHandling:
strMsg = Cstr(Err) + " : " + Error$ + " ([Revise A Policy] - Line " +Cstr(Erl) + ")"
Msgbox strMsg, 0+16, "Error - Please Contact Support with the Information contained in this message."
Exit Sub
End Sub