jen
10/17/2018, 11:42 PMfunction populateRECoverages() {
// Get the record we are on right now.
var re = currentRecord.get();
// Get the record we are copying from.
var copy_re_id = 12345;
var copy_re = record.load({
type: 'returnauthorization',
id: copy_re_id,
isDynamic: true,
});
var copy_re_line_count = copy_re.getLineCount({sublistId: 'item'});
for(var i = 0; i < copy_re_line_count; i++) {
console.log('adding line ' + i + ' item ' + copy_re.getSublistValue({sublistId : 'item', fieldId : 'item', line : i}));
// Get the line, and add it to our current RE.
re.selectNewLine({sublistId: 'item'});
// Set all of these, starting with the item.
var item_id = copy_re.getSublistValue({sublistId : 'item', fieldId : 'item', line : i});
console.log('adding item...');
re.setCurrentSublistValue({
sublistId: 'item',
fieldId: 'item',
value: item_id,
fireSlavingSync: true
});
// PROBLEM! Console displays "done" but line doesn't appear yet in UI
console.log('done...');
// Do other stuff like setting itemoptions and other column values properly here...
// PROBLEM! Doesn't work if this is an itemoption, because those aren't populated yet!
/*re.setCurrentSublistValue({
sublistId: 'item',
fieldId: 'custol_some_other_field',
value: 1
});*/
// Save the line
re.commitLine({
sublistId: 'item'
});
}
}