
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-20-2013 06:55 PM
I have a category in my Service Catalog for Loaner Items. (PC Mice Etc.)
This category will not require an approval.
My default work flow for ALL Service Request is to go to the requested for manager and get approval.
I want to add an IF condition that states IF the only category on the request is the Loaner Category, then bypass the approval state. I was going to use an if statement in the workflow and use a custom script to do this. If the only category is "Loaner" then mark approved. Carry on forward form there.
Is there a better way to do this? Does anyone have a custom script similar to what I am try to do I can borrow and customize to my category?
Thank you.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-23-2013 11:50 PM
So According to your logic, If your request contains loaner category's item along with any other Category's item, then it should go for approval. Right, So I hope below script resolves your query. Write this script in your Advance IF Activity in workflow :
var count = 0;
var c = 0;
answer = ifScript();
function ifScript() {
var rec = new GlideRecord('sc_req_item');
rec.addQuery('request', current.sys_id); // finding all related Request Items corresponding to the current Request
rec.query();
count = rec.getRowCount(); // getting the number of items raised within a request
while (rec.next()) {
if (rec.cat_item.category == '49d84ff7417f41003307c49932f92b2d')
{ c = c+1; // Making the count of the number of Items raised from the Loaner category
}
}
if(c != count) // If Request consist of item along with Loaner category's item, then Go for Approval
{ return 'yes';
}
else { // If request consist of only Loaner Category's item, then skip approval
return 'no';
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-08-2019 12:43 PM
Thank you so much.It worked!!!!!

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-08-2019 01:29 PM
Awesome glad it worked for you.