If requested for is a member of assignment group no need approval else approval needed

latha13
Tera Contributor

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

1 ACCEPTED SOLUTION

Sourabh26
Giga Guru

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.

View solution in original post

8 REPLIES 8

Sourabh26
Giga Guru

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.

Hi,

 Tried with above code but not working Approvals are triggering if requested for is not member of assignment group..

Thanks

 

latha13
Tera Contributor

Approval are not triggering if requested for is not member of assignment group..

Thanks

Hi Sourabh,

Code is working fine..

Thank you