I have a SuiteLet with an empty sublist. A button on the SuiteLet directs to a Client Script which is attempting to populate the sublist. I'm encountering a strange error on my Client Script—"undefined is not an object (evaluating 'olddata[i]')." This is a JavaScript error, I believe referring to "rec" in the following code. The error initiates on "rec.commitLine."
function populateSublist(fieldValues, rec, availableItems) {
log.debug("Rec", rec);
if (availableItems[0]) {
for (i = 0; i < availableItems.length; i++) {
try {
rec.selectNewLine({
sublistId: 'custpage_items_sublist'
});
rec.setCurrentSublistValue({
sublistId: 'custpage_items_sublist',
fieldId: 'custpage_parent_frame',
value: availableItems[0].item_parent_frame
});
// More values being set...
rec.commitLine({ // <=== *** RIGHT HERE ***
sublistId: 'custpage_items_sublist'
});
} catch (e) {
log.error("Unable to commit line - " + e.name, e.message);
}
}
} else {
log.debug("No available items for given parameters.")
}
Here are some things I know:
- "rec" is working previously and getting field names I need.
- "rec" is showing "{"id":"","type":null,"isDynamic":true}" in my execution log.
- The beginning of my Client Script uses
var rec = cr.get();
to receive the record.
Is it possible to modify a SuiteLet sublist from a Client Script? I've never done this in particular before, so I'm at a loss here. Any help or ideas are immensely appreciated! Thanks!