Changing Owner of workspace not recognizing lastName in Security.searchUser

Changing Owner of workspace not recognizing lastName in Security.searchUser

trentearley
Advocate Advocate
801 Views
3 Replies
Message 1 of 4

Changing Owner of workspace not recognizing lastName in Security.searchUser

trentearley
Advocate
Advocate

Hello, I am running this script to change the owner of the workspace to the CSR.

 

var username = item.CSR;
var nameArray = username.split(",");
var lName = nameArray[0];
var fName = nameArray[1];
var userINFO = Security.searchUsers({lastName:lName, firstName:fName});
item.master.owner = Security.loadUser(userINFO[0].id);

 

I am getting an error saying "cannot get "id" from undefined".

But when I remove the firstName:fName from the Security.searchUser command it works.

So my question is, Why is the firstName not being recognized by the searchUser command?

Thanks,

Trent

0 Likes
Accepted solutions (1)
802 Views
3 Replies
Replies (3)
Message 2 of 4

jmarsh76
Explorer
Explorer

I think it's a simple syntax error.  For the line var nameArray=userName.split(", "); you need a blank space after the comma.

0 Likes
Message 3 of 4

nguyentru
Alumni
Alumni
Accepted solution

Hi Trent,

 

Try using this script.

 

var userName = item.CONTENT_DEVELOPER_1[0];
println(userName);

if(userName !==null){

var nameArray = userName.split(", ");
var LName = nameArray[0];
var FName = nameArray[1];
var users = Security.searchUsers({lastName:LName, firstName:FName});

item.master.owner = users[0];

}


You also find out more information from one of our Developer - http://justonesandzeros.typepad.com/blog/

I hope this help.

thanks,

Trung
Trung Nguyen | PLM Product Management | Autodesk, Inc.
0 Likes
Message 4 of 4

trentearley
Advocate
Advocate

Thank you! I figured I was missing something obvious. 

0 Likes