Last active
January 25, 2023 15:20
-
-
Save W3BGUY/ecf874b078d8db5ae07c746d8eebade4 to your computer and use it in GitHub Desktop.
NetSuite SuiteScript 2.0 - Search for Inventory Items and return an array of all active items.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require(['N/search','N/record'],function(search,record){ | |
function buildItemArray(){ | |
var itemArray=[]; | |
searchItems(); | |
itemArray=runSearch(itemArray); | |
deleteSearch(); | |
log.debug(itemArray); | |
} | |
function searchItems(context){ | |
var itemSearch=search.create({ | |
type:search.Type.INVENTORY_ITEM, | |
title:'Inventory_Item_Search', | |
id:'customsearch_inventory_item_search', | |
columns:['internalid','itemid'], | |
filters:['isinactive','is','F'] | |
}); | |
itemSearch.save(); | |
} | |
function runSearch(itemArray){ | |
var mySearch=search.load({id:'customsearch_inventory_item_search'}); | |
mySearch.run().each(function(result){ | |
var item={}; | |
item.itemID=result.getValue({name:'itemid'}); | |
item.internalID=result.getValue({name:'internalid'}); | |
itemArray.push(item); | |
return true; | |
}); | |
return itemArray; | |
} | |
function deleteSearch(){ | |
search.delete({id:'customsearch_inventory_item_search'}); | |
} | |
buildItemArray(); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment