Hi All is there anyway to know complete employee h...
# suitescript
c
Hi All is there anyway to know complete employee hierarchy in Netsuite? I have a use case where I need to check record owner supervisor, based on that I have to restrict showing some button in suitelet. Either record owner or his supervisor or his supervisor can only access that record as we are giving editonly in role. We have to mimic that behavior
n
Maybe you can do it on a custom role and check the role on the SuiteLet. Alternatively one or more searches depending on if you can perform a join on the info you want.
c
Thanks @NElliott, I am not able to find how to do joins any suggestions on that please. We tried SQL queries as well CTE are not working as expected with joins to do recursion.
n
You can only jump off once, so for instance if you are searching on an employee and want to check a value of their supervisor you can do so but that's as deep as you can go. What exactly are you trying to search on?
(at least with the N/search module cannot speak to N/query)
c
When we give Edit only permission on custom record, he can edit his own or his subordinates records. Use case : employee A -> employee B -> employee C B is supervisor of C and A is supervisor of B So when we give Edit only permission A can edit records created by B and C along with his own records. B can edit his own and C records. Now if A tries to access record created by C, we don't know whether he is supervisor to C. We only get to know B as record owner supervisor. (By searching document owner supervisor). In the same way if there are multi level hierarchy we can't determine whether top one is supervisor or not with simple search. Core by default will take care of this for custom records. But as we are working on suitelet (on clicking edit or view we are opening suitelet) we have to take care of that functionality
n
Not that tricky if that's as deep as it goes. Search for B's where A is supervisor. Use those results to search for C's where B is supervisor. You know A, you know all B's that have A as supervisor and you know C that has B as supervisor. You could do this recursively building a table of individuals and their hierarchy and reference it. Or am I missing something?
(entirely possible)
c
Yes this is one solution we have I mind, but it needs recursive search till we find the logged in user value in supervisor hierarchy. If the level goes too much deep more searches should be done. But just trying to figure out can we get in single search /query. Thanks for your suggestions @NElliott
n
I would say definitely no to a single search with N/search, maybe look at the N/query module? Others here have / do use N/query and may be better placed to advise.
c
Sure @NElliott