Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

Need to add "Cancel" UI action button on change form?

Shiva prasad t
Tera Guru

I want to add cancel UI action on change form.

whenever we click that button at in any state it should be move to cancel state like OOB process, except when the state is closed. But here it's hiding when the it is in review state also.

find_real_file.png

This is the condition :

gs.hasRole('itil,sn_change_write') && new ChangeFormUI(current).isCancelAvailable()

This is the script what i wrote : 

var changeConfirmCancelDialog;

function setChangeCancelState() {
    g_form.setValue("state", "4");
}

if (typeof window == 'undefined')
   setRedirect();

function setRedirect() {
    current.update();
    action.setRedirectURL(current);
}

1 ACCEPTED SOLUTION

Pavankumar_1
Mega Patron

Hi,

Please add the condition on UI action form, when these conditions are true UI action will display.

refer the below image. ex: if the state value is -5 or 2 UI action will display.

if you want to display the UI  action in review state add the review state value in the condition.

find_real_file.png

 

Hope it helps!!

Please Mark Correct/helpful, if applicable, Thanks!! 

 

Regards

Pavankumar

If it helps please click Accept as Solution/hit the Thumb Icon.
ServiceNow Community MVP 2024.
Thanks,
Pavankumar

View solution in original post

2 REPLIES 2

Jaspal Singh
Mega Patron
Mega Patron

Hi Shiva,

ChangeFormUI seems to be a script include with funciton isCancelAvailable

Check out the script to understand the logic that is hiding the button

Pavankumar_1
Mega Patron

Hi,

Please add the condition on UI action form, when these conditions are true UI action will display.

refer the below image. ex: if the state value is -5 or 2 UI action will display.

if you want to display the UI  action in review state add the review state value in the condition.

find_real_file.png

 

Hope it helps!!

Please Mark Correct/helpful, if applicable, Thanks!! 

 

Regards

Pavankumar

If it helps please click Accept as Solution/hit the Thumb Icon.
ServiceNow Community MVP 2024.
Thanks,
Pavankumar