Marc
02/19/2025, 6:21 PMCeligo AI
02/19/2025, 6:21 PMAI generated answer (using internal Slack threads):To track how long a specific serialized item has been in stock in NetSuite, you can use a combination of saved searches, SuiteScript, or SuiteQL. Here's a general approach: 1. Saved Search: Create a saved search that tracks the inventory detail of the item. You can include fields like 'Date', 'Inventory Number', 'Quantity', 'Type' (e.g., Purchase, Sales, Transfer), etc. This will give you a list of all transactions related to that specific serialized item. 2. SuiteScript or SuiteQL: Use SuiteScript or SuiteQL to calculate the number of days the item was in stock. You can do this by finding the difference between the 'Date' when the item was received in stock and the 'Date' when it was shipped to a customer. Here's a pseudo-code example:
javascript
var itemId = '1234'; // replace with your item's internal id
var searchResult = nlapiSearchRecord('inventoryDetail', null,
[new nlobjSearchFilter('internalid', null, 'anyof', itemId)]);
var inStockDate, outStockDate;
for (var i = 0; i < searchResult.length; i++) {
var record = searchResult[i];
if (record.getValue('type') === 'Purchase') {
inStockDate = new Date(record.getValue('date'));
} else if (record.getValue('type') === 'Sales') {
outStockDate = new Date(record.getValue('date'));
}
}
var daysInStock = (outStockDate - inStockDate) / (1000 * 60 * 60 * 24);
Please note that this is a simplified example and may not cover all scenarios. You might need to adjust the code to handle multiple purchases and sales of the same item, backorders, returns, etc.
Also, if you are comfortable with SuiteQL, you can use Tim's Suitelet to get a report like you mentioned as it can be used for serialized inventory. You can find more details about it [here](https://timdietrich.me/blog/netsuite-inventory-balance-history-suitelet/).
******
Disclaimer:
This response was generated by an artificial intelligence assistant based on previous conversations from multiple Slack channels, and may contain inaccuracies or mistakes.
******Celigo AI
02/19/2025, 6:22 PMSlack thread 1: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.861018658
Slack thread 2: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.852579474
Slack thread 3: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.851163328
Celigo AI
02/19/2025, 6:22 PM