In script, I'm setting text field value from selec...
# ask-stanley-ai
n
In script, I'm setting text field value from selections made in a employee multiple select field. It currently lists employees selected with their ID shown instead of their name. How can I update this in the script to pull name values of employees selected in Multiple select field?
c
AI generated answer (using internal Slack threads):
In order to pull the name values of employees selected in a multiple select field, you would need to use a search in your script. The search would take the internal ID of the employee (which you are currently getting from the multiple select field) and return the name of the employee. Here is a basic example of how you could do this in SuiteScript:
Copy code
javascript
var employeeId = // get the employee ID from the multiple select field
var employeeSearch = search.create({
   type: search.Type.EMPLOYEE,
   filters: [
      search.createFilter({
         name: 'internalid',
         operator: search.Operator.ANYOF,
         values: [employeeId]
      })
   ],
   columns: ['firstname', 'lastname']
});

employeeSearch.run().each(function(result) {
   var firstName = result.getValue({name: 'firstname'});
   var lastName = result.getValue({name: 'lastname'});
   var fullName = firstName + ' ' + lastName;
   // set the text field value to the full name
   return true; // continue to the next result
});
This script creates a search on the Employee record type, filters for the specific employee ID, and returns the first name and last name of the employee. It then concatenates these into a full name and sets the text field value to this full name. ****** Disclaimer: This response was generated by an artificial intelligence assistant based on previous conversations from multiple Slack channels, and may contain inaccuracies or mistakes. ******
Slack thread 1: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.84345448
Slack thread 2: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.841797888
Slack thread 3: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.828686714
Please provide your feedback on this answer.