- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-28-2016 03:09 PM
I'd like to force a variable to be mandatory on my catalog task to be mandatory when the catalog task form is being submitted AND state = closed complete (3).
I tried doing this with a business rule, and it sort of works.. but the "Close Complete" UI action bypasses it as it forces a redirect and this apparently doesn't work in conjunction with .setAbortAction.Trying to look for some alternatives as I would like the entire page to stop loading/redirecting when using the Close Complete button, or setting to Closed Complete manually, and make the variable mandatory:
- (function executeRule(current, previous /*null when async*/) {
- if(current.variables.offboard_desktoprecoverassets == '' && current.state == "3"){
- current.state=previous.state;
- current.setAbortAction(true);
- gs.addInfoMessage('NOTICE: Please select an option for desktop recovery below completing the task.');
- gs.setRedirect(current);
- }
- })(current, previous);
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-28-2016 05:01 PM
You can write a onSubmit client script and put this script in there
function onSubmit() {
var ritm= g_form.getReferenec("request_item");
if((g_form.getValue('state')==3) && (ritm.cat_item=='Your cat item sys_id')){
if(g_form.getValue('variables.<variable_name>')==''){
g_form.setMandatory('variables.<variable_name>',true);
return false;
}
}
}

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-28-2016 03:47 PM
I am sorry I am confused.
Is your req to make field mandatory on catalog task for a particular item only? Correct me if I am wrong.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-28-2016 03:53 PM
Yes, exactly that.
I have made a UI policy to hide the variable on the catalog item form, and then in the workflow manually added the variable to the catalog task activity. This would display the variable to the necessary ITIL user working on the catalog task, and I want it only be mandatory when the catalog is being moved to a "Closed Complete" state - otherwise the ITIL user is free to update work notes etc and update the record without committing to choosing an option on the variable, but then being forced to one they go to complete the task.
Hopefully this makes more sense.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-28-2016 04:01 PM
Thanks Shane for the update.
You can dot-walking to request item fields if this is defined on catalog task
If that's not the case then you can write if logic in Catalog UI policy as below
var caller = g_form.getReference('request_item');
var catItem = caller.cat_item;
if(catitem == 'HARDCODE SYS_ID HERE')
{
//your logic
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-28-2016 04:31 PM
I am not seeing options to filter dot walk, as the filter is only showing variables as this is a Catalog UI Policy:
Screenshot: http://i.imgur.com/YdTQ7X1.png
Additionally, I don't see the ability to write that kind of If logic into the advanced script area:
Screenshot: http://i.imgur.com/Qszm7i9.png

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-28-2016 05:01 PM
You can write a onSubmit client script and put this script in there
function onSubmit() {
var ritm= g_form.getReferenec("request_item");
if((g_form.getValue('state')==3) && (ritm.cat_item=='Your cat item sys_id')){
if(g_form.getValue('variables.<variable_name>')==''){
g_form.setMandatory('variables.<variable_name>',true);
return false;
}
}
}