JSON onCreateJSON Function
You can use a new JSON entry point called onCreateJSON on the onCreate event of a record. The onCreateJSON function prompts the user with a warning or question before creating a record.
The onCreateJSON function in the following example code prompts the user with a message that an address is being created under the parent Account.
<html><head><title>onCreateJSON Example</title><script type="text/javascript"> /** sample script to warn if creating address under Account **/ function onCreateJSON(){ return "[{\"action\":\"select\",\"invoke\":\"getParent\",\"parameters\":[{\"modulefields\":[{ \"module\":\"1\", \"fields\":\"uid\"}],\"filter\":\"1.uid=$parent.uid\"}]}]"; } function getParent(row){ if(row.length>0) { /** it means that we are creating address under Account parent**/ return "[{\"action\":\"showprompt\",\"invoke\":\"callbackWithButtonTitle\",\"title\"\"$confirm.address.create\",\"otherbuttontitles\":[\"create\"],\"cancelbuttontitle\":\"cancel\" }]"; }else { return "[ {\"action\":\"validate\",\"result\":\"true\"} ]"; } } function callbackWithButtonTitle(otherbuttontitle1) { if(otherbuttontitle1 == "create"){ return "[ {\"action\":\"validate\",\"result\":\"true\"} ]"; }else { return "[ {\"action\":\"validate\",\"result\":\"false\"} ]"; } } function onErrorInvoke(rows){ if(rows.length > 0){ window.location = "melt://showAlert/" + message; } } </script></head><body></body></html>
Please see the section JSON Showprompt Action for more information about prompting.