I have created a suitelet with a sublist . In that...
# suitescript
s
I have created a suitelet with a sublist . In that Sublist i have one list field . Based on the value selected on that field , I have to add list options to the next ‘list field’. For eg., if im chosing a subsidiary in a field . i wanted all the items associated with the that subsidiary in the next drop down field. ( Note : these fields are in line level i.e, sublist fields). Using client script , i have tried with sublist changed entry point . But it only triggers when one line is inserted , not immediately when i chose the subsidiary field. So Please suggest an idea or already built solution or links i could refer that could help me with this problem . Or suggest any new idea for handling this issue .   Thanks in advance !
m
Did you try fieldChanged entry point?
s
Yes I tried field changed . It worked fine with body fields of suitelet. Since these are sublist fields . I could not approach like the same.
m
fieldChanged fires for sublist fields
s
yes it is firing in sublist fields , but i can not get the field object to insert select options . it is throwing an error "SSS_INVALID_SUBLIST_OPERATION".
function fieldChanged(context) {
var rec=context.currentRecord; if(context.sublistId == 'custpage_sublist' && context.fieldId=='custpage_productgroup') { var location = rec.getCurrentSublistValue('custpage_sublist','custpage_productgroup'); alert(location); if(location == '') return; var vendorSearch = search.create({ type: 'employee', filters: [['location','is',location]], columns: ['entityid'] }); var vendorSearchResults = vendorSearch.run().getRange({ start: 0, end: 1000 }); var vendfield = rec.getSublistField({ sublistId:'custpage_sublist', fieldId:'custapage_item', line:0 }); vendfield.removeSelectOption({value : null}); if(vendorSearchResults.length != 0) { for(var i in vendorSearchResults) { vendfield.insertSelectOption({ value : vendorSearchResults[i].id, text : vendorSearchResults[i].getValue('entityid') }); } } } } return { fieldChanged : fieldChanged };
what am i missing !
y
message has been deleted
error is from “removeSelectOption”
you may try to override the option values
s
hi @Yatin Karia the currentRecord.getSublistField itself not working , the actual error is "JS exception SSS_INVALID_SUBLIST_OPERATION CurrentRecord.getSublistField.
The line before the "removeSelectOption"
I can insert select option to an body field successfully using the same code . like when i change the list field in sublist , one of the body field got sourced with list with
var vendfield=rec.getField('custpage_vendor');
But why cant i get the sublist field ? using
var vendfield = rec.getSublistField({
sublistId:'custpage_sublist',
fieldId:'custapage_item',
line:0
});
y
ummmmm this should work
I suggest to try getSubrecord(), like address under order
It may help