- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-26-2016 11:50 AM
Is it viable to have Cancel Request UI Button on Task form and Request Item form and once the user clicks the button, a message should popup as a warning. How would you do it? Any suggestions?
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-26-2016 03:02 PM
You will have to add a client side code to UI action. I have just added the popup message to the OOB UI action 'Cancel request'
Here is the script for that
function cancelRequest(){
var submitFlag= confirm("If you cancel request, workflow will be stopped");
if(!submitFlag){
return false; //Abort submission
}
//Call the UI Action and skip the 'onclick' function
gsftSubmit(null, g_form.getFormElement(), 'cancel_request'); //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.request_state = 'closed_cancelled';
current.update();
new UIActionUtils().approvalsNoLongerRequired(current.sys_id);
}
This link will be helpful on how to write both client side and server side code in a single UI action
Client & Server Code in One UI Action - ServiceNow Guru
Thanks,
Abhinay
PS: Hit like, Helpful or Correct depending on the impact of the response
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-26-2016 01:02 PM
Hi,
You can create UI Action on Task form by using the following link:
In UI Action you can script using a Glide Dialog Window for displaying a popup with warning message required in a UI Page, for reference you can use below link:
Displaying a Custom Dialog - ServiceNow Wiki
You can also create a Client Side UI Action and display the warning message using a alert statement if you don't want to use a dialog window.
Please let me know if it answers your question and helps.
Thanks,
Manik
PS - Please mark correct, helpful and like if applicable.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-26-2016 01:06 PM
Hi Manik,
Thanks. I am not very good in scripting. Can you guide me how would I accomplish this?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-26-2016 02:24 PM
Hi,
What is your use case here other than popup message?
Thanks,
Abhinay
PS: Hit like, Helpful or Correct depending on the impact of the response
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-26-2016 02:38 PM
The use case, if for some reason, the itil user says task cannot be completed and want to cancel the request completely, they should have a UI button to do so. When they do, a popup message should be there to say them "if you cancel request, workflow will be stopped"