nathanw
11/19/2020, 11:00 PMsetMatrixSublistValue
?
I'm loading an item record and setting the MSRP using setMatrixSublistValue
.
I'm then calling itemRecord.save()
.
Is that all that I need to do or is there a matrix sublist commit or any like that?battk
11/19/2020, 11:04 PMbattk
11/19/2020, 11:04 PMnathanw
11/20/2020, 1:08 AMvar priceSublistCount = itemRecord.getLineCount({ sublistId: 'price1' });
for (var priceSublistLine = 0; priceSublistLine < priceSublistCount; priceSublistLine++) {
var selectedLine = itemRecord.selectLine({ sublistId: 'price1', line: priceSublistLine }); // Don't know if this is needed
var selectedPriceLevel = itemRecord.getCurrentSublistValue({ sublistId: 'price1', fieldId: 'pricelevel', line: priceSublistLine });
itemRecord.setMatrixSublistValue({
sublistId: 'price1',
fieldId: 'price',
column: 0,
line: priceSublistLine,
value: priceData[selectedPriceLevel]
});
//TODO: DOES THIS WORK?
itemRecord.commitLine({ sublistId: 'price1' });
}
}
itemRecord.save();
battk
11/20/2020, 2:05 AMbattk
11/20/2020, 2:05 AMbattk
11/20/2020, 2:06 AMbattk
11/20/2020, 2:06 AMRaj Konds
11/20/2020, 2:19 AMisDynamic: true
when loading the item record. Also yes itemRecord.selectLine({ sublistId: 'price1', line: priceSublistLine }); is needed. Hope this helps. All the best!battk
11/20/2020, 2:21 AMRaj Konds
11/20/2020, 2:23 AMnathanw
11/20/2020, 6:35 PMvar itemRecord = recordModule.load({
type: recordModule.Type.LOT_NUMBERED_ASSEMBLY_ITEM,
id: productId,
isDynamic: true
});
var priceSublistCount = itemRecord.getLineCount({ sublistId: 'price1' });
for (var priceSublistLine = 0; priceSublistLine < priceSublistCount; priceSublistLine++) {
var selectedLine = itemRecord.selectLine({ sublistId: 'price1', line: priceSublistLine });
var priceLevel = itemRecord.getCurrentMatrixSublistValue({ sublistId: 'price1', fieldId: 'pricelevel', column: 0 });
log.debug('Line: ' + priceSublistLine, 'PriceLevel: ' + JSON.stringify(priceLevel));
itemRecord.setCurrentMatrixSublistValue({ sublistId: 'price1', fieldId: 'price', column: 0, value: 0 });
itemRecord.commitLine({ sublistId: 'price1' });
}
nathanw
11/20/2020, 6:37 PM{"type":"error.SuiteScriptError","name":"SSS_METHOD_IS_ONLY_ALLOWED_FOR_MATRIX_FIELD","message":"Method is only allowed for matrix field."
nathanw
11/20/2020, 6:38 PMgetCurrentMatrixSublistValue
battk
11/20/2020, 6:41 PMbattk
11/20/2020, 6:42 PMnathanw
11/20/2020, 6:42 PMvar priceLevel = itemRecord.getCurrentSublistValue({ sublistId: 'price1', fieldId: 'pricelevel', line: priceSublistLine }); // dynamic
nathanw
11/20/2020, 6:43 PMnathanw
11/20/2020, 6:51 PM