Hi All, On a transaction Search I want to only sho...
# suitescript
r
Hi All, On a transaction Search I want to only show Sales orders that belong to a uses Subsidiary And Below. If the User is on the PARENT Subsidiary is there a easy way to get All the Subsidiary he has access too so I can pass it as a filter to the search? OR is there a search Filter that when I pass in a PARENT subsidiary ID it will give the Sales orders of the Children as well? TIA
n
Hi Reza, have you tried this?
r
Hey I was trying like User A belongs to SUB A (Parent SUB), Sales orders are in Sub B (child SUB). In the Code i have User A SUB ID only. How can I add a filter to show Sales order where Where SUB B sales order will come in the results as well
Cos I may have a user in the Parent Sub or in the Child Sub
n
I think this filter will show you sub B transactions in this case. but if you are saying dynamic context, (which means sub A is changing along with the current user), are you using this search in a script?
r
Yeah.. its a suitelet which is running as ADMIN. If i change it to run as User would solve this issue
but I need to run a schedule SCRIPT as well
n
i see. get the current user subsidiary first, then run a
subsidiary type
search, you will get subsidiaries sitting under the subsidiary that the current user belongs to.
r
yeah that might work
n
then transform this search result into an array, use it as a filter in your transaction search
r
thanks
once I get the Array of Subs i pass that into the Transaction Search
n
exactly. one question - what would be the subsidiary in script context in a scheduled script which is triggered by schedule?
r
I only need the transactions in the Suitelet
n
is that script owner's subsidiary or ... cuz currently the environment I got can only have one subsidiary
r
THAT works btw
bowtie 1
So transactions are on the CHILD SUB ( they have 3 child Subs)
employee can be on the child OR parent Sub
n
put the current user's sub in the array, too
r
yes 🙂
Copy code
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")
]
);
n
no ss20?
r
🙄
Yeah still in 1.0
are u full 2.0?
b
although im kinda late, you might want to consider the
mine or descendants
filter
[ "subsidiary", "anyof", "@HIERARCHY@" ]
🙄 1
r
thats what was looking for
n
😆
r
But if I only have the PARENT SUB ID
whats
@HIERARCHY@
??
b
its the internal id of the
mine or descendants
filter
for subsidiary, it would match any subsidiary that matches the current user's subsidiary or any of the descendants of that subsidiary
r
Never used it 😮
how would I write it
filters.push(new nlobjSearchFilter('subsidiary', null, 'anyof', params.userSubsidiary))
filters.push(new nlobjSearchFilter('subsidiary', null, 'anyof', '@HIERARCHY@'))
?
b
that second one
r
will give it a go
Hmm It didnt seem to work.. I changed my User to be on a child SUB (running as admin) but I can see parent Sales order too
b
oh well, good thing you still could lookup the subsidiaries for the current user
r
yeah but thanks for helping Didnt know about the
HIERARCHY
b
there should also be a
@CURRENT@
for
mine
and the more commonly known
@NONE@