Users, ALL by Name, pick list

Users, ALL by Name, pick list

Anonymous
Not applicable
1,451 Views
6 Replies
Message 1 of 7

Users, ALL by Name, pick list

Anonymous
Not applicable

I'm using the 

Users, ALL by Name pick list to get list of current users. once I have selected one user how would I go about getting that persons email address?

0 Likes
Accepted solutions (1)
1,452 Views
6 Replies
Replies (6)
Message 2 of 7

bastien.mazeran
Autodesk Support
Autodesk Support

Hi Tim,

This will require a behavior script.

You could use the Javascript split function to "split" your username selection in your picklist into two strings for firstName and lastName.

var selectedUser = item.USER_PL.split(", ");

From there you could construct a new user properties object, and set firstName and lastName as properties.

Then pass that user properties object to the Security.searchUsers() method and retrieve a new user object.

Finally set your email field to the email property found on your user object.

I hope this helps.

Regards,



Bastien Mazeran

Technical Support Specialist

Message 3 of 7

Anonymous
Not applicable

Great Help thanks, I didn't think it would be as involved as that.

I'll let you know how I get on.

0 Likes
Message 4 of 7

Anonymous
Not applicable
Accepted solution

Hi Tim,

 

I actually had the same question asked of me earlier so I figured I would share the full solution.

 

****Note: ****

This is based on a multi pick list and a scenario of 2 users with the same first and last name.

 

Solution:

var userName=item.APPROVALS_REQUIRED; // Get the users

var nameArray=userName[0].split(", "); // Split the name of user in question                                                       

var lName=nameArray[0]; // Last name

var fName=nameArray[1]; // First name

var userInfo=Security.searchUsers({lastName:lName, firstName:fName}); //find the user

var userEmail=userInfo[0].email; //return email of user in question

Message 5 of 7

Anonymous
Not applicable

HI Joe,

 

With a little help this is what I ended up with.

 

 

var selectedUser = item.ENGINEER.split(", ");
var user = Security.searchUsers({ lastName: selectedUser[0], firstName: selectedUser[1] });

if (!item.ENGINEER_EMAIL) {
//println(user[0].email);
item.ENGINEER_EMAIL = user[0].email;
}

Message 6 of 7

Anonymous
Not applicable

Tim,

 

Nice solution as well. 

0 Likes
Message 7 of 7

Anonymous
Not applicable

Tim and Joe,

 

Nice solution and thank you,

 

Great example of the new Security.searchUser function.

 

This along with pre-filtered picklist will make for many many options for workflow and notification assignments and checking with some inteligence to the options presented to the users

 

Much more useful

 

Thanks again.

 

Bob D

0 Likes