how do I filter products in netsuite by susidiary
# ask-stanley-ai
b
how do I filter products in netsuite by susidiary
c
AI generated answer (using internal Slack threads):
****** Disclaimer: This response was generated by an artificial intelligence assistant based on previous conversations from multiple Slack channels, and may contain inaccuracies or mistakes. ****** To filter products in NetSuite by subsidiary, you can use the
subsidiary
field in a search filter. Here's a general approach: 1. First, get the current user's subsidiary. You can do this by using the
nlapiGetContext().getSubsidiary()
function in SuiteScript 1.0 or
runtime.getCurrentUser().subsidiary
in SuiteScript 2.0. 2. Next, run a
subsidiary type
search to get subsidiaries sitting under the subsidiary that the current user belongs to. 3. Transform this search result into an array. 4. Use this array as a filter in your product search. Here's a sample code snippet in SuiteScript 1.0:
Copy code
javascript
var subsidiarySearch = nlapiSearchRecord("subsidiary",null,
[
   ["parent","equalto","1"]
], 
[
   new nlobjSearchColumn("name").setSort(false), 
   new nlobjSearchColumn("city"), 
   new nlobjSearchColumn("state"), 
   new nlobjSearchColumn("country"), 
   new nlobjSearchColumn("currency")
]
);
You can also consider using the
mine or descendants
filter. This filter matches any subsidiary that matches the current user's subsidiary or any of the descendants of that subsidiary. Here's how you can use it:
Copy code
javascript
filters.push(new nlobjSearchFilter('subsidiary', null, 'anyof', '@HIERARCHY@'))
Please note that the
@HIERARCHY@
is the internal id of the
mine or descendants
filter.
Slack thread 1: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.810311794
Slack thread 2: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.810026109
Slack thread 3: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.805886388
Please provide your feedback on this answer.