Fusion Manage Forum
Welcome to Autodesk’s Fusion Manage (formerly Fusion 360 Manage) Forum. Share your knowledge, ask questions, and explore popular Fusion Manage topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Condition Script Approval Groups

5 REPLIES 5
SOLVED
Reply
Message 1 of 6
Anonymous
761 Views, 5 Replies

Condition Script Approval Groups

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

Tags (1)
5 REPLIES 5
Message 2 of 6
jpiggee
in reply to: Anonymous

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(..)

Joseph Piggee
Fusion 360 Administrator
TPI Composites
jpiggee@tpicomposites.com
Message 3 of 6
Anonymous
in reply to: jpiggee

Hi Joe,

Thanks for the response. I'm not getting errors but the script is returning false so when I have it set up like this :
//If the creator of the Document Change Order is Saoirse Colgan let those in CCU Product Engineering approve the item
//Else if the item Creator is Ronan Kierans set the Approval group to Users in CCU Sales
var userCanApprove = false;
var creator = item.descriptor.createdBy;
if (creator === 'Saoirse Colgan' && Security.inGroup(userID, 'ST CCU Product Engineering') === true) {
userCanApprove = true;
println(creator);
}
else if (creator === 'Ronan Kierans' && Security.inGroup(userID, 'ST CCU Sales') === true) {
userCanApprove = true;
println(userID);
}
returnValue(userCanApprove);

For Items that I have created (Saoirse Colgan) Users in the CCU Product Engineering don't have permission to perform.

Thanks for your help.

Saoirse
Message 4 of 6
jpiggee
in reply to: Anonymous

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')

Joseph Piggee
Fusion 360 Administrator
TPI Composites
jpiggee@tpicomposites.com
Message 5 of 6
Anonymous
in reply to: jpiggee

Hi Joe,

Thanks for the response, I have it looking at the User ID now but it still returns false when a User from CCU Engineering is looking at an item created by 'Saoirse Colgan'. I've tried using nested if statements instead of && operator but regretfully no change.

//If the creator of the Document Change Order is Saoirse Colgan let those in CCU Product Engineering approve the item
//Else if the item Creator is Ronan Kierans set the Approval group to Users in CCU Sales
var usr = Security.loadUser(userID);
var usrName = usr.lastName + ", " + usr.firstName;
var creator = item.descriptor.createdBy;
var userCanApprove = false;

if (Security.inGroup(userID, 'ST CCU Product Engineering'&& creator === 'Saoirse Colgan' ) === true) {
userCanApprove = true;
println(creator)
}
else if (Security.inGroup(userID, 'ST CCU Sales') === true && creator === 'Ronan Kierans') {
userCanApprove = true;
}
returnValue(userCanApprove);
Message 6 of 6
jpiggee
in reply to: Anonymous

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***

Joseph Piggee
Fusion 360 Administrator
TPI Composites
jpiggee@tpicomposites.com

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report