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
Solved! Go to Solution.
Solved by jared.sund. Go to Solution.
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);
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