- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-22-2020 11:28 PM
Scenario: There is a catalog item where a field is "Requested for".
Expected sol: I have to check in workflow that "Requested for" is logged in user OR "Requested for" has Itil role.
How to achieve this through workflow in "If Activity" ?
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-22-2020 11:38 PM
Hi Vishal,
You can do check using
if( gs.getUserID() == current.variables.requested_for || gs.getUser().getUserByID(current.variables.requested_for).hasRole("itil") )
return "yes";
else
return "no";
Thanks,
Akash

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-22-2020 11:38 PM
you can write script in workflow if activity by checking advanced check box:
copy script as
// This script needs to set answer to 'yes' or 'no' to indicate the state of the activity.
//
// For example,
//
answer = ifScript();
var requestor = current.variables.requested_for + ""; //verify field name
function ifScript() {
if (requestor == gs.getUserID()) {
return 'yes';
}
var roles = new GlideRecord('sys_user_has_role');
roles.addQuery('user', requestor);
roles.addQuery('role.name', 'itil');
roles.query();
if(roles.next()){
return 'yes';
}
return 'no';
}
Thank you,
Ali
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-23-2020 12:08 AM
i tried but not working

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-23-2020 12:19 AM
Can you share your activity screenshot here? also the workflow is on sc_req_item table? is workflow struck at if activity or it is always going to else?
Thank you,
Ali