Fusion Manage Forum
Welcome to Autodesk’s Fusion Manage (formerly Fusion 360 Manage) Forum. Share your knowledge, ask questions, and explore popular Fusion Manage topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

How to get item owner name and assign the name to another field for that record?

3 REPLIES 3
SOLVED
Reply
Message 1 of 4
jdow
704 Views, 3 Replies

How to get item owner name and assign the name to another field for that record?

I have the following script to get the owner of a record to then put that owner name into a picklist field...the owner name i'm retrieving will match a name in the picklist.  I can get the owner name but can't assign it to the APPROVALS_REQUIRED field (the picklist).  Is this possible?

 

var oName=item.master.owner; // Get the owner name of the record

//var arName=item.APPROVALS_REQUIRED; //Get the approved_required field user name

var nameArray=oName.displayName.split(" "); // Split the name of user into an array by firstname / lastname

 

var fName=nameArray[0]; // First name

var lName=nameArray[1]; // Last name

var userINFO = Security.searchUsers({lastName:lName, firstName:fName}); //Find the user

 

item.APPROVALS_REQUIRED=Security.loadUser(userINFO[0].id);  //Changes approvals_required to owner name.

item.APPROVALS_REQUIRED=(lName+","+fName);

 

Thanks,

John

JD
3 REPLIES 3
Message 2 of 4
jared.sund
in reply to: jdow

John, 

 

I think there's a much simpler way to do this.  The following should work, assuming that APPROVALS_REQUIRED is a multi-select pick list.

 

Try this:

 

 

item.APPROVALS_REQUIRED.add(item.master.owner.lastName + ", " + item.master.owner.firstName);

Jared Sund
Sr. Product Line Manager, Product Lifecycle Management
Autodesk, Inc.
Message 3 of 4
jdow
in reply to: jared.sund

Awesome...much easier...works great...thank you.

 

How would this change it this is a single select picklist?

Is there a remove username option from a multi-select pick list?

 

John

JD
Message 4 of 4
gasevsm
in reply to: jdow

Hi, it would be something like: item.SINGLE_APPROVAL_REQUIRED = item.master.owner.lastName + ", " + item.master.owner.firstName;

Also check if your picklist displays users as 'last, first' or 'first last' and adjust your script accordingly.

--
Martin Gasevski

Martin Gasevski | Fusion 360 Team Product Manager

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report