Trying to get count of specific line items in Purchase Order

I am working through a Suitescript with a Purchase Order where some line items are billed and some are not – I need to get a count of the lines that are billed. Here is the code I am using but I continue to get j=0 – what am i doing wrong?

var purchaseOrder = record.load({

type: record.Type.PURCHASE_ORDER,

id: poID

});

 

 

var j = 0;

 

for (var i = 0; i < totallinecount; i++) {

 

 

var billed = purchaseOrder.getSublistValue({

sublistId: ‘item’,

fieldId: ‘quantitybilled’,

line: i

});

log.debug(‘#’, billed);

 

if (billed != ” && billed != null) {j += billed}

 

 

 

}

log.debug(‘j’,j)

Rookie Asked on March 21, 2023 in SuiteScript.
Add Comment
1 Answer(s)
Best answer

Are you missing a quotation mark in the first section of your if statement?

Rookie Answered on March 22, 2023.
Add Comment

Your Answer

By posting your answer, you agree to the privacy policy and terms of service.
  • This site made possible by our sponsors:   Tipalti   Celigo   SuiteMigration   Become a Sponsor