Is it possible to remove an option from a native d...
# ask-stanley-ai
t
Is it possible to remove an option from a native dropdown field in a record by script,if then how?
c
AI generated answer (using internal Slack threads):
Based on the conversations, it appears that it is not possible to directly remove an option from a native dropdown field in a record by script. However, there is a workaround that you can use: 1. Hide the native field that you want to edit the list of. 2. Create a new temporary field to hold the values you want. This can be done using a User Event (UE) script. 3. When you save the record, have a piece of code in beforeSubmit that copies the selected value in your custom field to the native field. Here is a sample code snippet provided in the conversation:
Copy code
javascript
var newContField = scriptContext.form.addField({
    id: 'custpage_contactfield',
    type: serverWidget.FieldType.SELECT,
    source: 'contact',
    label: 'Contact V2',
    layoutType: 'normal'
})
And in the Client Script (CS) pageInit:
Copy code
javascript
function pageInit(scriptContext) {
    var myRecord = scriptContext.currentRecord;
    var newField = myRecord.getField({fieldId: 'custpage_contactfield'}); // field added through a UE BL script

    newField.removeSelectOption({value: null, })
}
Please note that you cannot remove select options from a field that's sourced. You can only remove options if you use field.addSelectOption to add them. ****** 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.848080814
Slack thread 2: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.84685123
Slack thread 3: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.841239095
Please provide your feedback on this answer.