- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-04-2021 11:08 AM
I just want to make sure this makes sense..
We have 1 Tier 2 who refuses to leave notes... super fun. So when my Tier 1 team goes to check on a Catalog task and we see its been completed by this admin, we have no idea if he actually did what was asked.
I want to make it mandatory that when you press the CLOSE TASK button, you have to add notes
My thought is the following
1. Add the Close Notes field to the Form Design - this I can do
2. How do I make it Mandatory for them to fill it in when Close Task is clicked?
If I am not mistaken I do this
1. Configure UI Policy
2. Add new Policy - Condition State = Closed Complete - Close_notes Mandatory = True
Seems to work in Dev
Is there an easier way?
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-04-2021 11:01 PM
Using new UI policy on sc_task table to set Work Notes as Mandatory during State Changes to Closed Complete is the easiest way.
This would avoid touching the OOB "Close Task" UI Action
I would recommend using UI Policy based approach
1) Ensure for your UI Policy On Load checkbox is False
2) Also ensure if you wish to make this run only for some catalog items then add UI Policy condition as
Request Item.Cat Item [IS] Your Item Name
If you wish to use Script on the OOB UI Action then refer comments from Aman
Demo here:
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
05-04-2021 11:17 AM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-04-2021 11:18 AM
Hi,
UI Policy is the easiest way, but if you want to accommodate the code within the UI Action itself then follow the thread.
Please mark Correct✅/helpful if applicable, thanks!!
Aman
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-04-2021 02:20 PM
i like this answer, but I do not know how I get into that Script?
Can you tell me how to access it?
I think I found it, but not sure
I was able to right click and go to UI Actions
Then filter down to on Form actions
Close Task
It has the following in it currently, so I am not sure if this is the right spot
function closeTask(){
g_form.setValue('state', 3);
//Call the UI Action and skip the 'onclick' function
gsftSubmit(null, g_form.getFormElement(), 'close_sc_task');
}
//Code that runs without 'onclick'
//Ensure call to server-side function with no browser errors
if (typeof window == 'undefined')
updateTask();
function updateTask(){
current.state = 3;
current.update();
}

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-04-2021 10:35 PM
In the code you have already update as follows
function closeTask(){
if(g_form.getValue('close_notes') == '') {
try {
g_form.hideFieldMsg('close_notes');
}
catch(e) {}
g_form.setMandatory('close_notes', true);
g_form.showFieldMsg('close_notes', getMessage('Please enter supporting close notes when closing the change task'), 'error');
return false; // Abort submission
}
gsftSubmit(null, g_form.getFormElement(), 'close_sc_task');
}
//Code that runs without 'onclick'
//Ensure call to server-side function with no browser errors
if (typeof window == 'undefined')
updateTask();
function updateTask(){
current.state = 3;
current.update();
}