let statusField = form.addField({
id: ‘custpage_cus_filter’,
type: serverWidget.FieldType.MULTISELECT,
label: ‘Customer’,
container: ‘custpage_filtergroup’
});
// Update the display size
statusField.updateDisplaySize({
height: 2,
width: 275
});
// Update the layout type
statusField.updateLayoutType({
layoutType: serverWidget.FieldLayoutType.OUTSIDEABOVE
});
// Perform a saved search to get customer company names
let customerSearch = search.create({
type: search.Type.CUSTOMER,
filters:
[
[“stage”,“anyof”,“CUSTOMER”]
],
columns: [‘internalid’,‘companyname’]
});
let searchResults = customerSearch.run().getRange({
start: 0,
end: 1000
});
// Add options to the multi-select field from the search results
searchResults.forEach(function(result) {
let companyId = result.getValue(‘internalid’);
let companyName = result.getValue(‘companyname’);
statusField.addSelectOption({
value: companyId,
text: companyName
});
});