- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-14-2022 04:01 AM
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
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();
});
}
}
Solved! Go to Solution.
- Labels:
-
Problem Management
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-14-2022 05:44 AM
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;
}
}

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-14-2022 04:36 AM
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
Regards,
Musab
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-14-2022 04:45 AM
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
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-14-2022 04:49 AM
I have both the requirements.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-14-2022 05:44 AM
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;
}
}