How can I insert inventory detalis to Assembly build?

Hello,

I have a process that takes CSV file, convert them to JSON and then I need to insert the values to inventory details in Assembly build.

example of 1 line of JSON:

{“assembly”:”45″,”lotnumber”:”2021 109 M 21 – 1″,”Expiry date”:”12/05/2023″,”quantity”:”682″}

as you can see I need to insert the lot number, date and quantity .

 

my code:

for (var field in lotData) {
            if (field== ‘assembly’) {
                lotData[field] = getAssemblyId(lotData[field])
                assemblyBuild = record.load({
                    type: context.record.Type.ASSEMBLY_BUILD,
                    id: lotData[field],
                    isDynamic: true
                });
            }
            var inventoryDetailRecord = assemblyBuild.getCurrentSublistSubrecord({
                sublistId: ‘item’,
                fieldId: ‘inventorydetail’
            });
            inventoryDetailRecord.selectNewLine({
                sublistId: ‘inventoryassignment’
            });
            if (field== ‘lotnumber’) {
                inventoryDetailRecord.setCurrentSublistValue({
                    sublistId: ‘inventoryassignment’,
                    fieldId: ‘issueinventorynumber’,
                    value: lotData[field]
                });
            }
            if (field== ‘quantity’) {
                inventoryDetailRecord.setCurrentSublistValue({
                    sublistId: ‘inventoryassignment’,
                    fieldId: ‘quantity’,
                    value: quantity
                });
            }
            inventoryDetailRecord.commitLine({
                sublistId: ‘inventoryassignment’
            });
        }
        assemblyBuild.save()

 

 

I am getting ERROR that’s says “Field inventorydetail is not a subrecord field.”,”stack”:

 

any idea how can I make this work?

Rookie Asked on May 19, 2021 in SuiteScript.
Add Comment
1 Answer(s)

Use Record.selectLine to select the line you want to update.

Advanced Answered on May 19, 2021.

select line of what? i dont get it…

on May 20, 2021.

You are using dynamic mode, you need to have an understanding of how the record works in the ui to successfully use dynamic mode. Specifically for sublists, you need to select the line you want to update, update the values in the columns you want, and then commit the line.

Your code does not select any line, which means you are working with the new line. Your code then tries to get the inventory detail. That will fail since the new line has no item and thus no inventory detail.

on May 20, 2021.
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   Limebox   Become a Sponsor   Become a Sponsor