Save message displaying second time

I have a form that has an approve and deny button. These buttons will only display when the document is in edit mode.Here is my issue - the document will have the status of “Awaiting Manager Approval” and the user presses the

Approve button and they are asked if they want to save the change. If they answer “Yes”, the change is saved,

if they answer “No”, the document closes which is what it should do and if they answer “Cancel”, the user is brought back to the document on the screen.

Here is my issue, when the document is “Awaiting Manager Approval”, and the user presses “No”, the document automatically closes as it should. When the document moves to the next step of “Awaiting Sales Approval”, the user

presses the Approve button and than presses No the same as in the previous step, but instead of automatically closing as it should the user is presented with the second message asking if they want to save the document.

I have looked at the code and both use the following script in the “Approve” button and there is nothing in the Query close event both on the subform or form.

Can anyone tell me why the message is displaying at the second step of the workflow? I don’t want the message to display since the user answered “No”.

Below is the code for the Approve button.

Thank you in advance for any comments.

Jean

Code for button in otusscript :

Sub Click(Source As Button)

Dim workspace As New NotesUIWorkspace

Dim askme As Integer

Dim tellme As Integer

Dim holdValue As String

Dim holdValue2 As String

Dim uidoc As NotesUIDocument

Dim doc As NotesDocument

Dim boxType As Long, answer As Integer

boxType& = MB_YESNOCANCEL + MB_ICONQUESTION

Set uidoc = workspace.CurrentDocument

Set doc = uidoc.Document

Dim num As Integer

If (uidoc.EditMode = True) And (DocWasSaved = False) Then

holdvalue = uidoc.EditMode			

askMe = Messagebox("Do you wish to continue?",  boxType&, "Continue?")

Select Case askme

		

Case 2

       'Equals Cancel response - no action - goes back into document.	

Case 6	

       'Equals Yes response - saves document		

       Call uidoc.FieldSetText("Action", "Approve")		

       Call uidoc.FieldSetText("PostAction", "Approve")

   Call uidoc.FieldSetText("SaveOptions", "1")

   Call uidoc.FieldSetText("CloseFlag", "Yes")				

   Call uidoc.Save				

   Call uidoc.close			

Case 7

  'User answered No, doesn't save and closes document.

  Call uidoc.Close			

End Select

Else			

End If	

End Sub

Subject: Suggestions

First of all, you have the line Set doc = uidoc.Document

in your code, but you never use doc in the code.

But I think you are on the right track. What I would do is to make the changes in the backend, after you close the document. However, what you have to remember is that when you close the document using uidoc.Close(), if any field has been changed, the user will get the prompt to save.

Here is a suggestion (untested):

Sub Click(Source As Button)

Dim ws As New NotesUIWorkspace

Dim uidoc As NotesUIDocument

Dim doc As NotesDocument

Dim result As Integer

Dim boxType As Long

boxType = MB_YESNOCANCEL + MB_ICONQUESTION

Set uidoc = workspace.CurrentDocument

result = Messagebox(“Do you wish to continue?”, boxType, “Continue?”)

Select Case result

Case 2

'Equals Cancel response - no action - goes back into document.

Case 6

'Equals Yes response - saves document and closes it

Call uidoc.Save()

set doc = uidoc.Document

Call uidoc.Close(True)

Call doc.ReplaceItemvalue(“Action”, “Approve”)

Call doc.ReplaceItemvalue(“PostAction”, “Approve”)

Call doc.ReplaceItemvalue(“SaveOptions”, “1”)

Call doc.ReplaceItemvalue(“CloseFlag”, “Yes”)

Call doc.Save(True,False)

Case 7

'User answered No, doesn’t save and closes document.

'Note: If any field has changed, the user will get the save yes/no prompt.

'I would add:

'Call uidoc.Save()

Call uidoc.Close

End Select

End Sub