I need to create a 'cancel' Ui button in the incident form

suryaogeti1
Tera Contributor

using Ui actions, I need to create a cancel Ui button in the service operations workspace, when we click cancel button, it should cancel incident and state should move to cancel state, by adding work notes as well, guide me the step-by-step process and script.
Thanks in advance

4 REPLIES 4

GlideFather
Tera Patron

Hi @suryaogeti1,

 

what you have tried yourself. COuld you possibly share your blockers, errors or your UI Action to review? :))

 

This is not to do your job but rather to get support, but the efforts shall go both ways

 

EDIT: you can just change the state, add comment and save it no?

_____
100 % GlideFather experience and 0 % generative AI

AndersBGS
Tera Patron

Hi @suryaogeti1 

 

Where do you experience issues in your configuration?

 

If my answer has helped with your question, please mark my answer as the accepted solution and give a thumbs up.

Best regards
Anders

Rising star 2024
MVP 2025
linkedIn: https://www.linkedin.com/in/andersskovbjerg/

pr8172510
Mega Guru

 

Hi @suryaogeti1 Screenshot 2026-04-16 202429.pngScreenshot 2026-04-16 202518.pngScreenshot 2026-04-16 202537.pngScreenshot 2026-04-16 202647.pngScreenshot 2026-04-16 202704.png,

I was able to implement this successfully in Service Operations Workspace using a UI Action.

Approach:

  • Created a UI Action on the Incident table
  • Enabled Workspace Form Button
  • Used Workspace Client Script to trigger the action
  • Used server-side script to update the record

 Workspace Client Script:

 

 
function onClick(g_form) {

if (!confirm("Are you sure you want to cancel this incident?")) {
return;
}

g_form.submit('cancel_incident');
}
 

 

 Server-side Script:

 

 
if (typeof window == 'undefined') {

current.work_notes = "Incident cancelled by " + gs.getUserDisplayName();

current.state = 8; // Cancel

current.close_code = "Closed/Resolved by Caller";
current.close_notes = "Incident cancelled";

current.update();

action.setRedirectURL(current);
}
 

 Result:

  • Clicking Cancel Incident shows a confirmation popup
  • On confirmation:
    • Incident state moves to Canceled
    • Work notes are added
    • Record updates successfully in Workspace

Tanushree Maiti
Kilo Patron

Hi @suryaogeti1 

 

Step by step instruction is given in this community post.

Refer : Create a cancel button in SOW 

 

 

Please mark this response as Helpful & Accept it as solution if it assisted you with your question.
Regards
Tanushree Maiti
ServiceNow Technical Architect
Linkedin: