Hi, For CustomerA we are meant to ensure that Cus...
# suitescript
e
Hi, For CustomerA we are meant to ensure that CustomerB always has the latest stock information about the CustomerA items based on the current stock by updates via a web request to the CustomerB Netsuite Instance. One way to do this is with a webhook on a user event on each item receipt, item fulfillment, administratieve transfer etc. Out of performance reasons we asked if we could do this in a Scheduled way every 15 minutes. The agreed. However now this value is not something that is tracked with system notes so the only way is to make a search on items and use the search field
locationquantityavailable
And then save all this as JSON to a custom record or txt file with one property per item internalid (7K+) and the corresponding current stock as value.
Copy code
{
  "1":5,
  "2":4
...
}
so it can be compare every 15 minutes and updated with changes. Now both methods seem a bit overkill. Any thoughts or experience with the same usecase?
n
You could potentially do a search on all inventory impacting transactions that were created within the last 15 minutes. Or however long your time between script executions are. Search returns all items impacted, and returns their current inventory count
b
not really the level of precision you want
have one custom field that you use to store the last time you do the search, script parameter usually work best
instead of 1 per item
im not sure what your search currently is, but you usually want to bound both sides of
locationquantityavailable
with one being when you last ran the search (the value of your custom field), and the other being the future value of your custom field
with that future value being pretty close to when the logic runs
e
Thanks @Nathan L & @battk I wil try this. It sounds pretty reasonable. And solves the need for saving everything in a file.
Works like a charm it seems
Copy code
const transactionSearchObj = search.create({
   type: "transaction",
   filters:
   [
      ["linelastmodifieddate","within","14/08/2023 0:00","16/08/2023 11:00"],
      "AND", 
      ["type","anyof","ItemShip","ItemRcpt","InvAdjst"]
      "AND", 
      ["mainline","is","F"], 
      "AND", 
      ["min(accounttype)","isnotempty",""]
   ],
   columns:
   [
      search.createColumn({
         name: "item",
         summary: "GROUP"
      }),
      search.createColumn({
         name: "location",
         join: "item",
         summary: "GROUP",
         label: "Location"
      }),
      search.createColumn({
         name: "locationquantityavailable",
         join: "item",
         summary: "MAX",
         sort: search.Sort.ASC
      })
   ]
});
You are a great help! thanks
👍 1