Sorry, my statement is too long...
I have a form,the form have a button and field:Button name and field name are track reason.
if i click the button , will show an options box(options box name is askme).Among the options,have an option,the name called "other" , and it's for user to write other track reason.
If i choose the "other",then will show a dialog box to write other track reason.If i write something in dialog box(example:test),the field will show test,and the dialog box will close.If i click "cancel" in the dialog box,the dialog box will close and the field will show nothing.
Following is the code for button:
data(0) = "New vendor"
data(1) = "More than tracked amount"
data(2) = "Change vendor"
data(3) = "other"
askme = ws.prompt(PROMPT_OKCANCELLIST,"Track reason","Please choose the reason..." , data(0) , data())
If askme = "" Then
Call uipr.FieldSetText("TRACK_MARK" ,"")
uipr.Refresh
Exit Sub
Else
If askme = data(0) Or askme = data(1) Or askme = data(2) Then
Call uipr.FieldSetText("TRACK_REASON" , askme + username(0) + " " + Cstr(temp_servertime) + ")" )
Else
Call ws.DialogBox("TrackComments" , True , True , False , False , False , False , "Please enter other reason..." , , True , False)
Call uipr.FieldSetText("TRACK_REASON" , "(" + uipr.FieldGetText("ANOTHER_REASON") + username(0) + " " + Cstr(temp_servertime) + ")" )
End If
End If
And now,my question is...How can i write the code "If i click "cancel" in the dialog box,the dialog box will close and the field will show nothing."? Because the problem is at here:
Call ws.DialogBox("TrackComments" , True , True , False , False , False , False , "Please enter other reason..." , , True , False)
Call uipr.FieldSetText("TRACK_REASON" , "(" + uipr.FieldGetText("ANOTHER_REASON") + username(0) + " " + Cstr(temp_servertime) + ")" )
Now,I click the "cancel",the dialog box will close,but the field will show(example: ( Ariel 2020/02/25 02:20:00PM)).
How should i do??????
You need to CHECK if the user pressed OK or cancel. At the moment you don't do this.
Change your code like that:
Dim ok as Variant
ok = ws.DialogBox("TrackComments" , True , True , False , False , False , False , "Please enter other reason..." , , True , False)
If ok then
Call uipr.FieldSetText("TRACK_REASON" , "(" + uipr.FieldGetText("ANOTHER_REASON") + username(0) + " " + Cstr(temp_servertime) + ")" )
Else
Call uipr.FieldSetText("TRACK_REASON" , "" )
End If
In addition I would suggest to use the backend class NotesDocument to set the text, then you can make the "TRACK_REASON"- field computed (Formula: @ThisValue) and the user cannot edit it directly. This is not possible when using frontendclass NotesUIDocument.
Then your code would be:
If ok then
Call uipr.Document.ReplaceItemValue("TRACK_REASON" , "(" + uipr.Document.GetItemValue("ANOTHER_REASON")(0) + username(0) + " " + Cstr(temp_servertime) + ")" )
Else
Call uipr.Document.ReplaceItemValue("TRACK_REASON" , "" )
End If