netsuite-rest-api

NetSuite Rest create itemFulfillment from salesOrder Transform with Lot #s


I have .Net App that creates an itemFulfillment from a salesOrder and updates it with information about what is shipped uing teh folloinw URL:

https://{{COMPANY_URL}}/services/rest/record/v1/salesorder/{{SOID}}/!transform/itemFulfillment

with a Body like:

{
"item": {
    "items": [
        {
            "orderLine": 1,
            "location": 16,
            "quantity": 2,
            "itemReceive": true
        },
        {
            "orderLine": 2,
            "location": 16,
            "itemReceive": false
        }

    ]
}

}

We now have some items that are Lot Controlled. And it's failing with: Error while accessing a resource. Please configure the inventory detail in line 1 of the item list.

I tried to change the body to:

{
"item": {
    "items": [
        {
            "orderLine": 1,
            "location": 16,
            "quantity": 2,
            "custcol_wayb_serial_number": "PI-NN001503",
            "inventoryDetail": {
                "inventoryAssignment": {
                    "items": [
                        {
                            "issueInventoryNumber": "22CWB08-2",
                            "quantity": 2
                        }
                    ]
                }
            }
        },
        {
            "orderLine": 2,
            "location": 16,
            "itemReceive": false
        }
    ]
}

}

But it is currently erroring out with: Error while accessing a resource. You have entered an Invalid Field Value 22CWB08-2 for the following field: issueinventorynumber.

From what I see online, when looking at what people have scripted, I may have to pass in the id of the inventoryNumber. But I only have the actual text of the lot #. When I try to query inventoryNumber, I may get multiple records if it's at multiple locations and I need to get just the one at a specific location. There doesn't seem to be a way to query by location.

So my questions are:

  1. How do I fix this code to solve the issue with create itemFulfillment?
  2. If I need the invetoryNumber's Id, how do I get it by lot # and location?

Currently I'm just trying to prototype this in PostMan. Once I have that working, I can code it easily in.Net.


Solution

  • The issue turned out that I do need to send the id of the itemNumber not the actual lot # for issueInventoryNumber. As for the multiple rows found when I tried to look it up, it was because they had mistakenly updated two SKU's with the same lot #, therefore looking up by just lot # returned multiple rows. It wasn't because of multiple locations.

    To do the look-up, I need to look-up by lot # and item. I ended up doing a Query to do this.

    Sample query:

    { "q": "SELECT n.id FROM inventorynumber n JOIN item i on n.item = i.id WHERE n.inventoryNumber = 'LT7995' and i.itemId = 'CSTPI-MS-002'" }