I have created a pick list with the pick list option as USER, ALL by name. This allows me to assign an individual as a resource. After creating this I need to have the selected USER's email address for a script to send him an email. It is not allowing me to make a derived field from that picklist.
If this isn't possible what are my options for assigning different people as a resource and emailing only that individual at certain transitions. Thanks.
Solved! Go to Solution.
Hello and Welcome.
Correct what you are trying to achieve cannot be done by derived fields, however a on creation or on edit script can pull the information from the user (by using the userid), and populate a given field with in the workspace with that users given email.
This will then allow you to call upon the email field and use that as the address to send the email in question.
Thanks Joe, That gets me part of the way. From the USER, ALL by Name pick list it will grab lastname and first name (Doe, John). I see no way of getting the email address from the last and first name. The Security.loaduser (userID) requires the login for Doe, John. How will I get the UserID for the All by Name pick list item? I see nothing in the script reference that shows this can be done. Thanks again
I had the same problem. See the following post;
I had to use a work-around. All of our system user names have the following format;
Example username: dkeeley
Example name: Keeley: David
Example email: email@example.com
As you have pointed out the only value that can be extracted from the pick list is the 'name' value. There's currently no way to get the associated email address by scripting. So instead I used some string scripting to convert the 'name' to the 'username' and then add a '@company.com' to the end of it. It seems to work well but has some limitations. For example the 'admin' user will not receive emails using this method (but some conditions can be built into the script to overcome this if necessary)
Hope this helps,
Thank is an excellent option, one I haven’t thought of.
As to the original concept, a script could create a userid from the first name and last name, if you uses a standardized userid, with would then give you access to everything.
Yes you are correct. As soon as you have created the use rid from the username then the email address can be extracted automatically.
Glad this helped. i've given the script for converting the username to user I'd in my original post.
var user_name_length = user_name.length;
var char_position = user_name.indexOf(',');
var letter = user_name.charAt(char_position + 2);
var user_surname = user_name.substring(0,char_position);
var user_id_temp = letter + user_surname;
var user_id = user_id_temp.toLowerCase();
var user_details = Security.loadUser(user_id);
email.to = user_details.email;