RE: Why I get duplicate lines?

I want to insert new lines to inventory details.

 

here’s my code:

lotlist is an array of object

lotData is one object looks like this

{“line”:”1″,”assembly”:”1″,”lotnumber”:”2021 109 M 21 – 1″,”Expiry date”:”12/05/2023″,”quantity”:”3000″}
function Run(lotList) {
    try {
        for (var i = 0; i < lotList.length; i++) {
            var lotData = lotList[i]
            log.debug(‘Run lotData ‘ + i, lotData);
            createInvDet(lotData, i);
        }
    } catch (e) {
        log.error(‘Run ‘ + i, e)
    }
}
function createInvDet(lotData) {
    try {
        var assemblyBuild;
        var assembId = getAssemblyId(lotData[‘assembly’])
        assemblyBuild = context.record.load({
            type: context.record.Type.ASSEMBLY_BUILD,
            id: assembId,
            isDynamic: true
        });
        var invDet = assemblyBuild.getSubrecord(‘inventorydetail’);
        invDet.selectNewLine(‘inventoryassignment’);
        invDet.setCurrentSublistValue(‘inventoryassignment’, ‘receiptinventorynumber’, lotData[‘lotnumber’]);
        invDet.setCurrentSublistValue(‘inventoryassignment’, ‘quantity’, lotData[‘quantity’]);
The problem is I am always getting only the first line twice.
2 times this line:
{“line”:”1″,”assembly”:”1″,”lotnumber”:”2021 109 M 21 – 1″,”Expiry date”:”12/05/2023″,”quantity”:”3000″}
dNina Rookie Asked on May 20, 2021 in SuiteScript.

Expect to share enough code to reproduce the problem. The code you shared is not enough to reproduce the problem. Running it would make no changes to any record.

on May 20, 2021.
Add Comment
1 Answers

Any idea someone?

Rookie Answered on May 23, 2021.
Add Comment

Your Answer

By posting your answer, you agree to the privacy policy and terms of service.