How do I add an empty option from a source value w...
# ask-stanley-ai
e
How do I add an empty option from a source value when creating a form without using add select option as I'm using "source"?
c
AI generated answer (using internal Slack threads):
To add an empty option from a source value when creating a form without using
addSelectOption
as you're using "source", you can use a custom list or record for the source. However, if you're sourcing from a specific record like 'customer' and want to filter out certain options, you might need to create an empty select field and then add select options based on the results of a search. Here's a general idea of how you might do this:
Copy code
javascript
var field = form.addField({
    id: 'myfield',
    label: 'My Field',
    type: serverWidget.FieldType.SELECT
});

var searchResults = search.create({
    type: 'customer',
    filters: ['custentity_third_party_billing', 'is', false],
    columns: ['internalid']
}).run().getRange({start: 0, end: 1000});

searchResults.forEach(function(result) {
    field.addSelectOption({
        value: result.getValue('internalid'),
        text: result.getText('internalid')
    });
});
In this example, we're creating a search that returns all customers who don't have a custom "third party billing" checkbox checked. We then add these customers as select options to our field. Please note that this is a workaround and might not be the most efficient solution if you're dealing with a large number of options. Also, this approach requires you to manually manage the options in your select field, which might not be ideal if the source data changes frequently. ****** 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.814765215
Slack thread 2: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.813691139
Slack thread 3: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.809933186
Please provide your feedback on this answer.