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?
Solved! Go to Solution.
Solved by jpiggee. Go to Solution.
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,
Great Help thanks, I didn't think it would be as involved as that.
I'll let you know how I get on.
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
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;
}
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