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

Hi @Ankur Bawiskar ,

 

in the same script I want to check if Additional comments as mandatory, When we are cliking on cancel if additional comments needs to fill, if not then it should show error message

@Gopal14 

I believe I have answered your original question.

To check field is mandatory simply check if field comments is empty

if yes then show error message and make it mandatory

I hope you can do this and enhance further based on your developer skills.

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

@Gopal14 

Hope you are doing good.

Did my reply answer your question?

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

Hi @Ankur Bawiskar ,

 

function cancelRecord() {
    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;
    }
    gsftSubmit(null, g_form.getFormElement(), 'mandatory_comments');
}

if (typeof window == 'undefined') {
    serverQualify();
}

function serverQualify() {
    current.state = 7;
    current.update();
    action.setRedirectURL(current);
    gs.addInfoMessage('The case has been successfully canceled.');
}
 
above is my code which is working fine in native view, However it is not working in workspace view

@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