Nour Khaled
04/17/2025, 9:59 AMCeligo AI
04/17/2025, 9:59 AMAI generated answer (using internal Slack threads):Based on the conversations, it appears that you cannot directly add a filter to the
source
attribute of the addField
method in SuiteScript. The source
attribute is used to populate the select field with values from a specific record or list, but it does not support filtering.
However, there are alternative ways to achieve the desired result:
1. You can create a search to retrieve the accounts of a certain type, and then loop through the results to add them as select options using the addSelectOption
method. Here is a sample code:
javascript
var accountField = form.addField({
id: 'custpage_account_select',
type: serverWidget.FieldType.SELECT,
label: 'Account',
container: "mainInfo"
});
var accountSearch = search.create({
type: 'account',
filters: [
['type', 'anyof', 'Bank']
],
columns: ['internalid', 'name']
});
accountSearch.run().each(function(result) {
accountField.addSelectOption({
value: result.getValue('internalid'),
text: result.getValue('name')
});
return true;
});
2. Another approach is to add all the options first by specifying a source
in addField
, and then remove the unwanted options using the removeSelectOption
method. However, this method might not be efficient if there are a large number of options to remove.
******
Disclaimer:
This response was generated by an artificial intelligence assistant based on previous conversations from multiple Slack channels, and may contain inaccuracies or mistakes.
******Celigo AI
04/17/2025, 9:59 AMSlack thread 1: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.881703854
Slack thread 2: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.857878506
Slack thread 3: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.837853134
Celigo AI
04/17/2025, 9:59 AM