How to create a custom cancel UI Action in case table

Gopal14
Tera Contributor

Hi Team,

 

How to create a custom cancel UI Action in case table for native view and workspace view

1 ACCEPTED SOLUTION

@Gopal14 

you need to write script in workspace client script.

if (g_form.getValue('comments') == '') {
g_form.setMandatory('comments', true);
g_form.addErrorMessage("You must add a reason in Additional comments in order to reopen an incident");
return false;
}

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

View solution in original post

19 REPLIES 19

@Ankur Bawiskar ,

 

I have added same code in workspace action, however in workspace after clicking on cancel, it is setting additional comments as mandatory, but nothing is happing in the form, means state is not changing to cancel

 

Gopal14_0-1738563212107.png

 

Gopal14_1-1738563239856.png

 

@Gopal14 

comments is mandatory so it wont' submit

update as this so that if comments are present it submits the form

after line 6 add this

g_form.setValue('state', '7');
    g_form.save();

 

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

@Ankur Bawiskar ,

 

I am adding comments and submitting the cancel button, however comments are updating, but state is not changing.

 

Gopal14_0-1738572845800.png

 

After clicking cancel button, state is not changing

 

Gopal14_1-1738572910830.png

 

@Gopal14 

any business rule is restricting the state change?

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

@Ankur Bawiskar ,

 

No, doing this in my pdi. Same code is working fine in native view