If condition in workflow for approval
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-25-2020 07:00 AM
I have to create an additional approval if level is division and name is Central data.
In my catalog item I have a variable called ‘Type’ referenced to ‘alm_hardware’ table I have to query the record selected in Type and check if level is division or not(level has 5 choices)
If level is not division, then it should check the record selected in parentID for level is division or not this process should repeat until level is division
ParentID is referenced to ‘alm_hardware’ table
If level matches with division check “Name’ field for Central data. (Name field is text field)
Here is the script I was working
You can refer to the word document attached
- Labels:
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-25-2020 07:26 AM
function ifScript()
//Glide the table
{if(current.variables.variableName=="")// pass the varaible name and variable correctly
return "yes";
else
return "no";
}

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-25-2020 08:04 AM
Hi,
Your script will be something like below. Please make sure to use the correct names and values for fields and choices in the script below.
answer = ifScript();
function ifScript()
var gr =new GlideRecord("alm_hardware");
gr.addEncodedQuery("sys_id"+current.variables.vType.toString());
gr.query();
if(gr.next()){
if(gr.getValue('u_level') == 'division'){
return "yes";
} else{
var parent = gr.parent.getRefRecord();
if(parent.getValue("u_level") == 'division'){
return true;
} else { return false;}
}
}
}
Hope that helps!
Regards,
Muhammad
Muhammad
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-25-2020 09:15 AM
In the line var parent = gr.parent.getRefRecord();
gr.parent, is the parent referring to ParentID field...??

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-25-2020 09:22 AM
yes, please replace it with the correct field name of ParentID.
Muhammad