Confirm Box (UI action)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-23-2022 12:03 AM
Hi,all
I would like to create a UI action to place a confirm box on table[u_test].
The content is confirmation of saving the record.
If Yes, the record is saved, and if No, it is treated as canceled and returns to the record form.
Would you please give me a code that above requirements?
Best Regards,

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-23-2022 12:07 AM
Hi,
confirm() works at client side. you have to use confirm in client side function and update part will be at server side.
Please have a look on below blog for further details about UI Action
https://servicenowguru.com/system-ui/ui-actions-system-ui/client-server-code-ui-action/
//Client-side 'onclick' function
function test(){
var usrResponse = confirm('Are you sure you want to transfer this request to incident?');
if(usrResponse == 'false'){
return false; //Abort submission
}
//Call the UI Action and skip the 'onclick' function
gsftSubmit(null, g_form.getFormElement(), 'test'); //MUST call the 'Action name' set in this UI Action
}
//Code that runs without 'onclick'
//Ensure call to server-side function with no browser errors
if(typeof window == 'undefined')
runBusRuleCode();
//Server-side function
function runBusRuleCode(){
current.transf_inc = true;
current.update();
gs.addInfoMessage('You did it!');
action.setRedirectURL(current);
}
Regards,
Vaishnavi Lathkar
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-23-2022 12:39 AM
Hi Vaishnavi,
Thank you for your reply.
As I mentioned confirm() above, the user's request is to put out a dialog to confirm execution to save the record.
Therefore, it does not have to be confirm(), and it is a view that alert() are fine.
Should I use the above code for alerts?
Also, if I copy and paste the above code verbatim, can I create a dialog that meets the requirements?