Tyler
12/30/2020, 8:17 PMfunction updateFieldOnAllLines(dataIn) {
if (!dataIn.rec || !dataIn.sublist || !dataIn.field) {
return;
}
var rec = dataIn.rec;
var sublist = dataIn.sublist;
var field = dataIn.field;
var ignoreFieldChange = dataIn.ignoreFieldChange;
var initLine = null;
for (var i = 0; i < rec.getLineCount(sublist); i++) {
if (!initLine) {
initLine = rec.getCurrentSublistIndex({
sublistId: sublist,
fieldId: field.fieldId
})
}
rec.selectLine({
sublistId: sublist,
line: i
});
rec.setCurrentSublistValue({
sublistId: sublist,
fieldId: field.fieldId,
value: field.fieldValue,
ignoreFieldChange: ignoreFieldChange || false
})
rec.commitLine({
sublistId: sublist
});
}
}
Here is the problem: There is another field on the sublist that sources the value from the first sublist field whenever that field changes. When the script goes through to update the sublist field, only the very first line gets updated, both the field I change via code and the field that gets sourced. When the script is finished running, I can see in the UI that the first line is still in edit mode which makes me think that the commitLine function is never running.
Things to note: When I use ignoreFieldChanged: true when setting the current sublist value, all the fields properly get set via code but, predictably, the sublist field that sources doesn’t change. I have tried using postSourcing instead of fieldChanged but I am running into the same issue. Also, when I console.log the value of the sublist field after committing the line, it is showing the correct value, though it still shows the old value in the UI.
Any help with this would be much appreciated!battk
12/30/2020, 9:52 PMTyler
12/30/2020, 9:59 PM