cancel button on problem table

Shiva prasad t
Tera Guru

currently i have one cancel button on problem form, which is visible only on assess and root cause analysis states. And, when we click on it the ui page is coming like this find_real_file.png

I don't have a problem with this.

the problem is before this comes up when we click on the button it will show warning message " Are you sure you want to cancel "ticket number""

And the Ui action should be visible at all states except resolved state.

this is the script i have 

Condition script:

current.canWrite() && new ProblemStateUtils().canMarkDuplicateOrCancel(current);

 

script :

function onCancel() {
    if (g_form && g_form.mandatoryCheck()) {
        ScriptLoader.getScripts("ProblemModalUIHelpers.jsdbx", function() {
            ProblemModalUIHelpers.problem_Cancel();
        });
    }
}

1 ACCEPTED SOLUTION

I added like this to the existing script. And it's working fine now.

function onCancel() {

 var answer= confirm("Are you sure you want to cancel Incident"   +g_form.getValue("number"));
   if (answer==true) {
    
 if (g_form && g_form.mandatoryCheck()) {
        ScriptLoader.getScripts("ProblemModalUIHelpers.jsdbx", function() {
            ProblemModalUIHelpers.problem_Cancel();
        });
    }

    else 
{
    return false;
}
   
}

View solution in original post

4 REPLIES 4

Musab Rasheed
Tera Sage
Tera Sage

Hello,

Just write below in condition

current.canWrite() && new ProblemStateUtils().canMarkDuplicateOrCancel(current) && current.state != '4';

Make sure '4' is backend value of resolved or add accordingly

Regards

Please hit like and mark my response as correct if that helps
Regards,
Musab

Ankur Bawiskar
Tera Patron
Tera Patron

Hi,

so what's your question? what is your requirement

1) UI action visibility -> you can update the condition as per your requirement

OR

2) that message shown -> " Are you sure you want to cancel "ticket number""

Regards
Ankur

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

I have both the requirements.

I added like this to the existing script. And it's working fine now.

function onCancel() {

 var answer= confirm("Are you sure you want to cancel Incident"   +g_form.getValue("number"));
   if (answer==true) {
    
 if (g_form && g_form.mandatoryCheck()) {
        ScriptLoader.getScripts("ProblemModalUIHelpers.jsdbx", function() {
            ProblemModalUIHelpers.problem_Cancel();
        });
    }

    else 
{
    return false;
}
   
}