5

GET .../record/v1/inventoryitem/155/locations/1

by using above api to get item quantity i got the below error

"title":       "Unknown (sub-)resource (i.e., sublist, sublist line, subrecord, 
                reference, ultiselect) locations in request URL.",
"status":       404,
"o:errorCode": "NONEXISTENT_ID"

Please anyone tell me which API I should have to use to get item available quantity.

Chidambaram S
  • 53
  • 1
  • 3
  • This request works for my records, so it would require more information from you. Are you sure that location with ID 1 does exist on inventoryitem record with ID 155? Request GET .../record/v1/inventoryitem/155/locations will return you all location IDs for a given Item. – Johny May 14 '20 at 06:51
  • Hi, Request GET .../record/v1/inventoryitem/155/locations-> return empty(as below) but 8 locations are exist for the record.[155 is item internal id] { "links": [ { "rel": "self", "href": "*****/record/v1/inventoryitem/155/locations" } ], "items": [], "totalResults": 0 } – Chidambaram S May 15 '20 at 10:11

2 Answers2

5

You can execute a SuiteQL query.

POST https://[account].suitetalk.api.netsuite.com/services/rest/query/v1/suiteql
Header: Prefer: transient
Body:
{
    "q": "SELECT item, location, quantityavailable FROM inventoryitemlocations WHERE item=155"
}

Sample output from my test account:

{
    "links": [
        {
            "rel": "self",
            "href": "https://[accountid].suitetalk.api.netsuite.com/services/rest/query/v1/suiteql?limit=1000&offset=0"
        }
    ],
    "count": 3,
    "hasMore": false,
    "items": [
        {
            "links": [],
            "item": "857",
            "location": "1",
            "quantityavailable": "50"
        },
        {
            "links": [],
            "item": "857",
            "location": "16",
            "quantityavailable": "50"
        },
        {
            "links": [],
            "item": "857",
            "location": "12",
            "quantityavailable": "50"
        }
    ],
    "offset": 0,
    "totalResults": 3
}

The record and field IDS are in the Analytics browser: https://[account].app.netsuite.com/help/helpcenter/en_US/srbrowser/Browser2020_1/analytics/record/inventoryItemLocations.html.

Jala
  • 889
  • 4
  • 9
  • 2
    Boy, it's hard to find the record/table names for SuiteQL. Was looking for inventoryitemlocations everywhere. I was looking under "I" in the analytics browser and for some reason, it's listed under "L" with a title of Locations. Also, why isn't it listed in the joins for the item table. SuiteQL looks great, but needs it's own records browser. – Ben Mills Jan 08 '21 at 22:35
  • @BenMills /app/recordscatalog/rcbrowser.nl?whence=#/record_ss/location This seems to be the record browser, but still not 100% – Brett Mar 22 '21 at 20:27
1

You can use the search api in your script to retrieve inventory item quantity from all locations. Below is a code snippet of search (created using SuiteScript 1.0 & 2.0) which is used to retrieve inventory quantities for all location of an item.

Search created using SuiteScript 1.0:

var inventoryitemSearch = nlapiSearchRecord("inventoryitem",null,
  [
   ["type","anyof","InvtPart"], 
   "AND", 
   ["internalidnumber","equalto","57"]    // Enter the internal id of item
  ], 
  [
   new nlobjSearchColumn("itemid"), 
   new nlobjSearchColumn("inventorylocation"), 
   new nlobjSearchColumn("locationquantityavailable")
  ]
);

Search created using SuiteScript 2.0:

var inventoryitemSearch = search.create({
  type: "inventoryitem",
  filters:
  [
   ["type","anyof","InvtPart"], 
   "AND", 
   ["internalidnumber","equalto","57"]  // Enter the internal id of item
  ],
  columns:
  [
   search.createColumn({name: "itemid", label: "Name"}),
   search.createColumn({name: "inventorylocation", label: "Inventory Location"}),
   search.createColumn({name: "locationquantityavailable", label: "Location Available"})
  ]
});

Additional Note: You can add extra columns in the search to retrieve more information on the item. You can also tune the search filter to retrieve information on many item records.