JSON Showprompt Action

The Showprompt action is a JSON action that allows you to present a dialog box with a message to the user, and wait for a response from the user. With Showprompt, you can perform soft validation in an onSave script so that a warning message is displayed before asking if you want to save the record or return to the record to fix the warnings.

When defining the Showprompt message, you must insert a dollar symbol ($) before the device message. The message that a Showprompt action displays is also used in button names (to allow for translation). The table below describes the request attributes in the Showprompt action.


Name

Description

Required

Default

action

This shows the alert prompt. The value for this attribute is showprompt. For example:
"action":"showprompt"

Yes

No

invoke

The function to invoke when the user selects a button in the prompt. The title corresponding to the selected button will be the parameter for this function.

Yes

No

title

The message to show in the prompt. It must start with a dollar ($) sign so that the title will be localized. (showAlert is localized in a similar way).

No

No

cancelbuttontitle

The title of the Cancel button. The Cancel button closes the alert box. The button title is localized.

No

No

otherbuttontitle

The titles of any other buttons that will be shown in the alert prompt. The titles of these buttons are passed as parameters to the invoke function. The button titles are localized.

Yes

No


An example Showprompt action is as follows:

return "[{\"action\":\"showprompt\",\"invoke\":\"promptFunction\",\"title\":\"You Are Creating Address Under An Account, Do You Want To Proceed?\",\"cancelbuttontitle\":\"cancel\", \"otherbuttontitles\":[\"yes\",\"no\"] }]"; 


When you apply the request attributes from the table above, the example Showprompt action translates to the following:

[{
action:showprompt 
invoke:promptFunction
title:You Are Creating Address Under An Account, Do You Want To Proceed? 
cancelbuttontitle:Cancel
otherbuttontitles yes, no)
}] 



The result of this Showprompt example is that an alert box with buttons is displayed to the user. When the user selects a button, the invoke function is called with the "clicked button title" as a parameter. For example:

function promptFunction(value) { 
	if(value == "yes"){
		return "[ {\"action\":\"validate\",\"result\":\"true\"} ]";
	}else if(value == "no"){
		return "[ {\"action\":\"validate\",\"result\":\"false\"} ]";
	}
} 


Please see the section titled JSON onCreateJSON Function for a full example using prompting.