1
votes

How do I get a package tracking number in a User Event script which will be fired on afterSubmit on an item fulfillment?

/**
 * @NApiVersion 2.0
 * @NScriptType UserEventScript
 * @NModuleScope SameAccount
 */
define(["N/record"], function (r) {
    function onAfterSubmit(context) {
        var currentRecord = context.currentRecord;
        var trno = currentRecord.lineitems.package[1].packagetrackingnumber;
    }

    return {
        afterSubmit: onAfterSubmit
    };
});

It is giving me an error like "package[1] is not in undefined", so the line item seems undefined here.

2
Have you logging the currentRecord.lineitems object? It looks like that's not the right attribute name on the ItemFulfillment object: netsuite.com/help/helpcenter/en_US/srbrowser/Browser2019_1/… - iloveitaly

2 Answers

0
votes

It is best to use NetSuite's API SuiteScript to access any data on a NetSuite record.

To get the packagetrackingnumber use currentRecord.getCurrentSublistValue(). To get the tracking number for each line you will have to traverse through the the sublist lines by using currentRecord.selectLine() in conjunction with currentRecord.getCurrentSublistValue().

0
votes

in SS 2.0 the numbering starts at 0 (not 1 like SS 1.0) you should try:

    var trno = currentRecord.lineitems.package[0].packagetrackingnumber;