Discussions
Stay up-to-date with the latest news from NetSuite. You’ll be in the know about how to connect with peers and take your business to new heights at our virtual, in-person, on demand events, and much more.
New AI Community Guidelines. Please review and follow them to ensure AI use stays safe, accurate, and compliant.
NSC | How to Combine Items in Sales Orders using SuiteScript
If you are working on Sales Orders that contain the same item in different rows and would like to combine them into one, here is a sample code that may help:
/**
*@NApiVersion2.x
*@NScriptTypeUserEventScript
*@NModuleScopeSameAccount
*/
define(['N/record'],
function(record){
/**
*Functiondefinitiontobetriggeredbeforerecordisloaded.
*
*@param{Object}scriptContext
*@param{Record}scriptContext.newRecord-Newrecord
*@param{string}scriptContext.type-Triggertype
*@param{Form}scriptContext.form-Currentform
*@Since2015.2
*/
function beforeLoad(scriptContext){
vararrItems=[],itemSummary=[];
varsalesOrd=record.load({
type:record.Type.SALES_ORDER,
id :4746
});
varitemCount=salesOrd.getLineCount('item');
itemSummary[0]=salesOrd.getSublistValue({
sublistId:'item',
fieldId:'item',
line:0
});
for(vari=0;i<itemCount;i++){
varitem=salesOrd.getSublistValue({
sublistId:'item',
fieldId:'item',
line:i
});
Refer a Member to the Community | Earn the Answer Accepter Badge | Vote for the contents you'd like to see
Tagged:
0
