- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-21-2015 10:04 AM
Hi All,
I have a variable which is displayed only on the catalog task form and I want to make it mandatory only when the State of the catalog task is updated to 'Closed Complete'.
In order to accomplish this I have a UI policy created which displays it only on the catalog task form and hides it elsewhere. Now the trouble I am having is how should I set up the condition where it should be mandatory only when the catalog task State changes to 'Closed Complete'?
Can it be done in the same UI policy or will I need a client script?
Any help would be appreciated.
Thanks!
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-21-2015 11:57 AM
I used a UI Policy to do this. I set the state to Closed complete and used this script
function onCondition() {
g_form.setMandatory('variables.preorder',true);}
And then the false version of this for the "reverse if condition is false".
I also had to add something to the "Close Task" button to ensure the UI Policy was checked before closing out the task utilizing that button. I believe I utilized this thread to accomplish that: https://community.servicenow.com/thread/183633
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-21-2015 10:12 AM
You can create a separate 'Catalog UI Policy' for this and make it mandatory when catalog task state is closed complete.
Service Catalog UI Policy - ServiceNow Wiki

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-21-2015 10:13 AM
Hi Mohammed,
You should use client script. Script will be something like.
var field1 = g_form.getControl('state');
if(field1.changed)
{
//Make field mandatory
}
Please let me know if you have any questions.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-21-2015 10:17 AM
It has to be separate. You want to create a new one for state is closed complete then make that field be mandatory

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-21-2015 10:18 AM
UPDATE: You can have a onchange client script and compare the old and new values and then make the field mandatory as per your req.
I hope that helps