I'm having trouble getting a condition script to work.
var userCanApprove = false;
var creator = item.descriptor.createdBy;
if (creator === 'Joe Bloggs' && Security.inGroup(userID, 'Engineering') === true) {
userCanApprove = true;
}
else if (creator === 'Paul Smith' && Security.inGroup(userID, 'Sales') === true) {
userCanApprove = true;
}
returnValue(userCanApprove);
So if Joe Blogs is the creator of the item the any Users in the Engineering group can apply. Can anyone see what is obviously wrong with this block of code?
Thanks
Saoirse
Solved! Go to Solution.
Solved by jpiggee. Go to Solution.
Saoirse,
What errors are you getting?
Also have you tried a println() for creator in-between line 4/5 and 6/7 to make sure you are pulling the proper information from the creator variable and also looking at proper information with Security.inGroup(..)
Saoirse,
You need to define the userID, at this point your not telling the Security.inGroup who to look at.
as in
var user = piggeej
Secruity.inGroup(user, 'Admin')
Saoirse,
I believe this is what you are looking to achieve.
***Start of script***
var creator = item.descriptor.createdBy; //find the creator of the item
var userCanApprove = false; // set default to false
var groupPE = Security.inGroup(creator, '*name of group to test against*'); //is user in this group (security)? - returns true or false
var groupSales = Security.inGroup(creator, '*name of group to test against*'); // is user in this group(security)? - returns true or false
if (groupPE === true && creator === '*place user id here* '){ // *place user id here* - add the id of the user you want to check against
userCanApprove = true; // if they are listed in the group and the creator id and id give match return true
}
else if (groupSales === true && creator === '*place user id here* ') { // *place user id here* - add the id of the user you want to check against
userCanApprove = true; // if they are listed in the group and the creator id and id give match return true
}
returnValue(userCanApprove); // return value
***End of script***