Need to set a value in a custom segment field in s...
# ask-stanley-ai
s
Need to set a value in a custom segment field in suitescript but only have the display value.
c
AI generated answer (using internal Slack threads):
To set a value in a custom segment field in SuiteScript using the display value, you can create a custom field in your code and control the select options. You can then mirror the user selection back into the 'real' field. Here is a general idea of how you can do it:
Copy code
javascript
var field = record.getField({fieldId: 'customfield'});
field.removeSelectOption({value: null}); // remove all options

// add new options
field.addSelectOption({value: 'internalid1', text: 'displayvalue1'});
field.addSelectOption({value: 'internalid2', text: 'displayvalue2'});
// and so on...
In this way, you can control what is displayed in the select field and then use the selected value to set the value in the actual field. Another approach is to create an additional field on the form, which defaults to the value of a different column of a record. This way, you can display a different value but still have the actual value set in the background. If you are dealing with a hidden field, you can set the field to normal display on the field configuration and on the form, but set the label on any form that you want it hidden from to an empty string. This hides the column field from the form but still allows scripts to access/manipulate it. ****** 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.822340369
Slack thread 2: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.818405509
Slack thread 3: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.817705512
Please provide your feedback on this answer.