R5 introduced some new Methods in the NotesUIWorkspace class. One of them is the PickListStrings method. Basically it's the equivalent of the @PickList in @Formulas but in Script --- so now you can prompt your users without jumping through hoops like we had to in the past (i.e. a @Formula agent that prompted the users followed by another one in Script).
Unfortunately, the documentation provided for this method states that if the user clicks Cancel on the prompt, the variable will be equal to Nothing.
I tried to catch the error with a nothing but it didn't work. So I used the IsNull and IsEmpty functions to get the results I wanted. See the code below.
'Declare the variant needed to capture the results Dim PickListResults As Variant 'Prompt the user ... PickListResults = NUIWS.PickListStrings( PICKLIST_CUSTOM , True , ServerName, RefProdDB , "(ProductSearch)" , "Select the Product(s)", "Select the Product(s) to add." , 1 ) 'Check to see if the user pressed Cancel If Isnull (PickListResults) Or Isempty (PickListResults) Then Print "No products selected ..." Exit Sub End If 'He didn't so add the products to the field ... note : the AnsellProductsField was declared prior to this and I didn't include all the code to keep this tip short. For i = 0 To Ubound ( PickListResults ) Step 1 Call ProductsField.AppendToTextList ( PickListResults(i) ) Next i