• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 261
  • Last Modified:

Logic for cancel in script is not working

I have a script that ask 3 questions before it creates the document.  The problem is at any one of the three questions if the user clicks cancel it should kick out of the script and not save the document.  Right now it goes on to the next question and then the next then saves the document

Sub Click(Source As Button)
      Dim ws As New NotesUIWorkspace
      Dim uidoc As NotesUIDocument
      Dim doc As NotesDocument
      Dim db As NotesDatabase
      Dim varReturn As Variant
      Dim strCodeType As String
      Dim intDECheck As Integer
      Dim intWNCheck As Integer
      Dim strOptions(0 To 1) As String
      Dim strDEFlag As String
      Dim strWNFlag As String
      
      Set db = ws.CurrentDatabase.Database
      strOptions(0) = "RIP"
      strOptions(1) = "Engine"
      
      varReturn = ws.Prompt(PROMPT_OKCANCELLIST, "Submit Release (step 1/3)", "What type of code release?", "", strOptions)
      strCodeType = varReturn      
      
      varReturn = ws.Prompt(PROMPT_YESNOCANCEL, "Submit Release (step 2/3)", "Does this RIP/Engine release require counterpart engine/RIP DE approval before releasing .mfg file?")
      intDECheck = varReturn
      
      varReturn = ws.Prompt(PROMPT_YESNOCANCEL, "Submit Release (step 3/3)", "Does it require WinCSU testing?")
      intWNCheck = varReturn
      
      If intDECheck = 1 Then
            strDEFlag = "Yes"
      Else
            strDEFlag = "No"
      End If
      
      If intWNCheck = 1 Then
            strWNFlag = "Yes"
      Else
            strWNFlag = "No"
      End If
      Set doc = New NotesDocument(db)
      doc.Form = "CodeRelease"
      doc.DECheck = strDEFlag
      doc.WinCheck = strWNFlag
      doc.CodeType = strCodeType
      Call doc.Save(True, False)
      
      Set uidoc = ws.EditDocument(True, doc)
End Sub
0
Jaziar
Asked:
Jaziar
1 Solution
 
HappyFunBallCommented:
After each call to ws.Prompt, you just need to check the value of the varReturn variable.  

From the documentation:

"For type% PROMPT_YESNOCANCEL, returns -1 if you select Cancel. For all other type%s the return value is a variant containing a string array if you press OK, and EMPTY if you press Cancel."

So after the first prompt, you can add this line:

If IsEmpty(varReturn) Then Exit Sub

For the other two add this line afterwards:

If varReturn = -1 Then Exit Sub
0
 
JaziarAuthor Commented:
Why is no one looking at my NAgMail?
0

Featured Post

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now