- 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 03:12 PM
Why do you want to check for wf_actvity? Do you want this to be only applied for one catalog task of this workflow?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-29-2016 03:35 PM
Yes, and I have just done that successfully! I got the catalog client script to do a check for the wf_activity and then modified the UI action script that you provided for the check for the wf_activity instead. Not checking for the catalog_item value.
You saved the day again
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-04-2017 12:11 PM
Did this solution still work for you after publishing a new version of your workflow? It appears the act of publishing creates a brand new wf_activity record. I thought this sounded like a good solution until I published a new version and the functionality that relied on that ID stopped working.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-16-2020 06:45 AM
Hi,
How can you get that can to tell me.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-28-2025 04:38 AM
I created this today based off some of my own work and some of the structure from peoples suggestions, this is a client script not a catalog client script, found this to be better as I could use it across multiple RITMS and have done so by using an array of values for the RITMs it should be actioned on
function onSubmit(){
var ritm = g_form.getValue("cat_item");
var cat_items = [Array of catalog items it should be active on here];
var state = g_form.getValue("state");
var variable1 = g_form.getValue(variables.variable1);
var variable2 = g_form.getValue(variables.variable2);
//variables will be specified by variables.variable_name
//if the state is closed complete and the catalog item being submitted is included on my array of RITM sys_ids specified above
if(state == 3 &&(cat_items.includes(ritm))){
//if varaibles are empty
if(variable1 == "" && variable2 == ""){
//set variables to mandatory
g_form.setMandatory("variables.variable1",true);
g_form.setMandatory("variables.variable2",true);
//return false to prevent submission
return false;
}
}
}