- 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-29-2016 02:15 PM
This generally works, but the "Closed Complete" button bypasses the script somehow and submits the page without making the variable mandatory.
Ideas?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-28-2016 05:34 PM
Hi Shane,
Thanks for the update. You are correct. If this is a catalog UI policy it will not show related fields. However it will show if you have created a UI policy on catalog task.
The second option I suggested earlier should go as part of client script. It was error on my side that I mentioned it as catalog UI policy.
Please let me know if you have any additional questions.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-28-2016 04:52 PM
I believe g_form.getReference(); does not work in UI policies. It will throw an error
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-28-2016 04:54 PM
You are talking about UI Actions and Business Rules. If it is ok for you to only enforce this on the client side, you could make an onSubmit client script (client script and not catalog client script) that would check for the current state and your variable before submitting. If the variable is empty then you would set the field mandatory and return false on that client script. This would cancel the save and force your user to set the variable to be able to save.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-29-2016 02:18 PM
Can you post the script in the Closed Complete Ui action?