SuiteScript to check whether the purchase order is fully received.

let poRecord = record.load({
    type: record.Type.PURCHASE_ORDER,
    id: poId,
    isDynamic: true,
});
let returnVal = true;
let numLines = poRecord.getLineCount({
    sublistId: 'item'
});

for (let i = 0; i < numLines; i++) {
    let quantity = poRecord.getSublistValue({
        sublistId: 'item',
        fieldId: 'quantity',
        line: i
    });

    let quantityReceived = poRecord.getSublistValue({
        sublistId: 'item',
        fieldId: 'quantityreceived',
        line: i
    });

    if (quantityReceived < quantity) {
        returnVal = false;
    }
}
return returnVal;

Here if purchase order is fully received true will be returned. Else, false will be returned.

Leave a comment

Your email address will not be published. Required fields are marked *