OK, this works in SuiteScript 1, but for some reason I can't get it to work with SuiteScript 2. What am I missing?
Client side (on field changed/on line changed) or server side (on submit), I can't alter the lines on a sales order, e.g. set a custom field.
Neither of these work. Either the function is not found or nothing happens. I've tried all sorts of different functions and combinations for setting the text or the value. I just doesn't seem to work:
1.
Rec.setSublistText({
sublistId : 'item',
fieldId : 'custcol_example',
line : i,
value : "A"
});
2.
Rec.selectLine({
sublistId : 'item',
line : i
});
Rec.setCurrentSublistText({
sublistId : 'item',
fieldId : 'custcol_example',
value : "A",
ignoreFieldChange: true
});
Rec.commitLine();
This works perfectly in SuiteScript 1
function clientFieldChanged(type, name, linenum) {
var Count = nlapiGetLineItemCount("item");
for (var i = 1; i <= Count; i++) {
nlapiSelectLineItem("item", i);
nlapiSetCurrentLineItemValue("item", "custcol_example", "A", false, false);
nlapiCommitLineItem("item");
}
}
As requested, a more complete SS2 example. Doesn't work.
function fieldChanged(scriptContext) {
var Rec = scriptContext.currentRecord;
var Count = Rec.getLineCount("item");
for (var i = 0; i < Count; i++) {
Rec.selectLine({
sublistId : 'item',
line : i
});
Rec.setCurrentSublistText({
sublistId : 'item',
fieldId : 'custcol_example',
line : i,
value : "A"
});
Rec.commitLine();
}
}