- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-12-2022 01:47 AM
Hello All,
Catalog Item having 2 fields requested for and assignment group here I want "If requested for is a member of assignment group no need to send approval else approval needed
If script in workflow
answer = ifScript();
function ifScript() {
var reqFor = current.variables.requested_for.toString() ;
if(reqFor.isMemberOf(current.variables.assignment_group.toString())){
return 'yes'; //no approval
}
return 'no';//trigger for approval
}
Above code is not working shows error in script..
Thanks
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-12-2022 02:48 AM
Hi,
Update your code as below.
answer = ifScript();
function ifScript() {
var userObj = gs.getUser();
var reqFor = userObj.getUserByID(current.variables.requested_for);
var grp = current.variables.assignment_group;
workflow.info('User = '+reqFor+' Group = '+grp);
if (reqFor.isMemberOf(grp)) {
workflow.info('YES');
return 'yes'; //no approval
}
workflow.info('NO');
return 'no'; //trigger for approval
}
Please mark the answer as correct/helpful based on impact.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-12-2022 02:48 AM
Hi,
Update your code as below.
answer = ifScript();
function ifScript() {
var userObj = gs.getUser();
var reqFor = userObj.getUserByID(current.variables.requested_for);
var grp = current.variables.assignment_group;
workflow.info('User = '+reqFor+' Group = '+grp);
if (reqFor.isMemberOf(grp)) {
workflow.info('YES');
return 'yes'; //no approval
}
workflow.info('NO');
return 'no'; //trigger for approval
}
Please mark the answer as correct/helpful based on impact.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-12-2022 03:09 AM
Hi,
Tried with above code but not working Approvals are triggering if requested for is not member of assignment group..
Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-12-2022 03:14 AM
Approval are not triggering if requested for is not member of assignment group..
Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-12-2022 03:34 AM
Hi Sourabh,
Code is working fine..
Thank you