- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-09-2023 07:00 PM
I have created an UI Action "Cancel Request" button as per below in the requested item table and I want to add the existing scripts when the assignee clicks on the UI Action "Cancel Request" button it will force or set a mandatory to fill in the close notes comment.
How can I do script it and thank you.
Condition
current.approval == 'requested'
Scripts
current.state = '4';
current.approval = 'Cancelled';
current.update();
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-09-2023 07:28 PM
Hi TMKAM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-09-2023 10:11 PM
Hi @TMKAM ,
try below script and give action name as reject_action and select Client check box.
Give onClick function name as reject() or any name must use same function on script.
function reject() {
g_form.setMandatory('close_notes', 'true');
var answer = confirm("Are you sure you want to Cancel Request?");
if (answer == true) {
gsftSubmit(null, g_form.getFormElement(), 'reject_action'); //MUST call the 'Action name' set in this UI Action
} else {
return false;
}
}
if (typeof window == 'undefined') {
current.state = '4';
current.approval = 'Cancelled';
current.setWorkflow(false);
current.update();
}
ServiceNow Community MVP 2024.
Thanks,
Pavankumar
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-10-2023 12:21 AM
Hi,
function onClick(){
g_form.setMandatory('work_notes', true);
}
Plz mark my Solution as Accept and Thumbs up, if you got any help from it.
Regards,
Samaksh
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-10-2023 12:44 AM
Hello @TMKAM
This is my Response,
Plz mark my Solution as Accept and Thumbs up, if you got any help from it.
Regards,
Samaksh
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-10-2023 12:41 AM
Hello,
I have also added the same line of code for that.
Can you pls mark my solution as Accept, it will help other users to reach out here.
Regards,
Samaksh