Derived field from Picklist

Derived field from Picklist

Anonymous
Not applicable
2,444 Views
7 Replies
Message 1 of 8

Derived field from Picklist

Anonymous
Not applicable

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.

0 Likes
Accepted solutions (1)
2,445 Views
7 Replies
Replies (7)
Message 2 of 8

Anonymous
Not applicable

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.

0 Likes
Message 3 of 8

Anonymous
Not applicable

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

0 Likes
Message 4 of 8

Anonymous
Not applicable
Accepted solution

Hi,

 

I had the same problem. See the following post;

 

http://forums.autodesk.com/t5/Autodesk-PLM-360/User-email-address-in-scripting/td-p/.UN_7wXwgGSM

 

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 protected]

 

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,

 

David. 

Message 5 of 8

Anonymous
Not applicable

David,

 

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. 

0 Likes
Message 6 of 8

Anonymous
Not applicable

Thanks for the help.  That is the direction I will go.

 

Scott

0 Likes
Message 7 of 8

Anonymous
Not applicable

Hi Joe,

 

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. 

 

david. 

0 Likes
Message 8 of 8

Anonymous
Not applicable

    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;