Thursday, 25 February 2021

HCM GET ORG AT PARTICULAR DEPTH

Query to get a org at a particular depth -

SELECT haou.name, haou.organization_id
, ANCESTOR_PK1_VALUE, DISTANCE
,haou1.name LEVEL1_ORG
FROM per_org_tree_node_rf prf, hr_all_organization_units haou
, hr_all_organization_units haou1
WHERE 1=1
AND pk1_value = haou.organization_id
AND ANCESTOR_PK1_VALUE = haou1.organization_id
AND DISTANCE = (CASE WHEN haou.name LIKE '%IDEN1%' THEN 1
WHEN haou.name LIKE '%IDEN2%' THEN 2
WHEN haou.name LIKE '%IDEN3%' THEN 3
ELSE 1 END
)

Instead of the hard coded distance calculation you could use the current node depth and get the node at a given level above.

No comments:

Post a Comment

Integrations Lead - Lessons learnt

 Integrations have been my passion for a while but like anything tech there is no credit given when things go right but always heaps of pres...