Autodesk PLM 360
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic to the Top
- Bookmark
- Subscribe
- Printer Friendly Page
User email address in scripting
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
Hi,
I have a script that needs to be able to access a user's email address to send an email. I'm having trouble working out the script to access this user item data.
So far I have something like this;
var user = item.TEAM[0];
var user_details = Security.loadUser(user);
var test = user_details.email;
The online help has something like this but I cant seem to work out how to use it correctly;
var users = Security.listUsersInGroup('Quality');
for(var index in users) {
email.to = users[index].email;
email.send();
}
Re: User email address in scripting
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
I've done a couple blogs with email examples - see if either of these get you what you need:
Hope that helps!
Michelle

Michelle Stone
PLM Product Manager
Autodesk, Inc.
Re: User email address in scripting
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
Hi Michelle,
I'm still having problems. Can you tell me how to extract the email address from a user that has been selected from a picklist?
David.
Re: User email address in scripting
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
Another example! Here's a picklist set up to all users and the script I use to send to whomever is selected.
Script:
Hope that helps!
Michelle

Michelle Stone
PLM Product Manager
Autodesk, Inc.
Re: User email address in scripting
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
Hi Michelle,
Thanks for the info. I think I can see what the problem is now.
If I'm correct the 'User, ALL' picklist contains user ids. That way you can access the email address using the Security.loaduser formula.
But I don't seem to have that picklist. I have a picklist called 'Users, ALL by Name' which returns the name of the user - not the id. So I don't think you can use Security.loaduser on a user's full name - you need the userid.
How can I go about replicating the 'User, ALL' picklist that you have shown in your screenshot?
David.
Re: User email address in scripting
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
Hi Michelle,
I have just tested my theory and I believe I am correct. You can see in the attached image that the email address is recovered correctly if I use a username (not the user's name). So to solve this issue I need to be able to do one of two things;
1. Create a user picklist that returns username (e.g. dkeeley) NOT the user name (e.g. David Keeley)
2. Find a way to get the email address from a user name.
In the meantime I've written the following script to do it (but its dependant on all usernames being in the same format);
var i = 0;
var team_size = item.TEAM.length;
var email = new Email();
email.subject = 'Comment Added to Special Project ' +item.NUMBER;
email.body = getPrintView('Project Comment Email');
while (i<team_size)
{
var user_name = item.TEAM[i];
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);
i++;
email.to = user_details.email;
email.send();
}
Re: User email address in scripting
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
Sorry David - that was a wicked old example I posted, but looks like you got it sorted out! Another example for extracting the user info from the picklist result (assuming you name the field PLM360_USER_NAME:
|
var user= item.PLM360_USER_NAME;
var securityInfo=Security.loadUser(user); item.FIRST_NAME=securityInfo.firstName; item.LAST_NAME=securityInfo.lastName; item.TITLE=securityInfo.title; item.MAIL=securityInfo.email; item.ORGANIZATION=securityInfo.organization; Thanks!
Michelle
|

Michelle Stone
PLM Product Manager
Autodesk, Inc.
Re: User email address in scripting
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
Hi Michelle,
The problem with this as I understand it is that for me the item.PLM360_USER_NAME = 'Keeley, David' NOT 'dkeeley'. The former value is not the userid so cannot be used to load user information.
I need a way to get the userid 'dkeeley' from the user name 'Keeley, David' OR I need to modify the picklist to return the userid instead of the user name.
Any thoughts?
David.
Re: User email address in scripting
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
David - there currently isn't a way to get the userid from a picklist, but they are working on it.

Michelle Stone
PLM Product Manager
Autodesk, Inc.
Re: User email address in scripting
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
Thanks for your help Michelle.
