Reputation: 69
I have a sublist in the record and a custom select field in the main. What I want is when I add a line in the sublist, load the record from that line, take some info from there and add them as options to the custom select field. All those I want them in a client script. I think in validate line event or otherwise. I have tried addSelectOptions but it throws 'SSS_NOT_YET_SUPORTED'. Also the select field is not sourced from anywhere
Any ideas?
Upvotes: 2
Views: 3143
Reputation: 4102
There are two "Field" api's (using suitescript 2.x) - one on the 'currentRecord' module, and one on the 'ui/serverWidget' module. Insert is used on the former, and add is used on the latter.
For the currentRecord module (from client script context):
if (scriptContext.fieldId === 'custpage_bdcvalue')
{
let currentRecord = scriptContext.currentRecord;
let bdcField = currentRecord.getField({ fieldId: 'custpage_bdcselectvalue', });
bdcField.removeSelectOption({ value: null, }); // clears all options
// bdcField.removeSelectOption({ value: 1, }); // removes the option with that key (value).
bdcField.insertSelectOption({ value: '', text: '', isSelected: false, });
bdcField.insertSelectOption({ value: '2', text: 'New option', isSelected: false, });
}
For the ui/serverWidget module (on a suitelet or restlet, etc):
let BDCSelectValueField = form.addField({
id: 'custpage_bdcselectvalue',
type: serverWidget.FieldType.SELECT,
label: 'BDC Select Value',
container: 'RetrievedDataEntry',
});
BDCSelectValueField.addSelectOption({ value: '', text: '', isSelected: true, });
Upvotes: 0
Reputation: 226
var fieldObject = currentRecordObject.getField({ fieldId: 'custpage_selecttestfield' });
// Insert a new option.
fieldObject .insertSelectOption({ value: 'Option1', text: 'Test1' });
Upvotes: 4