Reputation: 7
I have a client script runs on Suitelet. On Suitelet we have a sublist which has many select columns. Let's say we have Select 1 and Select 2. Select 2 options should be different if you change the option in Select 1. Could this be done in Client Script? or in that Suitelet? Any help would be appreciated. `
var select1= sublist.addField({
id: 'custpage_select1',
label: 'Select1',
type: ui.FieldType.SELECT
});
var select2= sublist.addField({
id: 'custpage_select2',
label: 'Select2',
type: ui.FieldType.SELECT
});
` In client script when the field is changed, I want to change options of Select 2 depend on Select 1.
function fieldChanged(scriptContext){
if(scriptContext.fieldId=="custpage_select1"){
let page = currentRecord.get();
var select2 = page.getField({fieldID:"custpage_select2"});
select2.removeSelectOption({value:"value1"});
}
}
But this shows me an error that
Cannot read properties of null
Thank you
Upvotes: 0
Views: 1460
Reputation: 3287
Yes. You can use the N/currentRecord
module in your client script with getField()
and removeSelectOption()
.
let page = currentRecord.get();
const select2 = page.getField({
fieldId: 'custpage_select2'
});
select2.removeSelectOption({
value: 'option1'
});
Upvotes: 1