How to setup transformation rule to map if an item is a child member of a (another) dimension parent

kustrup
New Contributor

I am looking to create a transformation rule for Accounts to map to a destination if the Department on the record is a child of a specific parent in the OS department dimension.

ACCT600 DEPT101  --> ACT_EXP600_100
ACTT600 DEPT321  --> ACT_EXP600_100

Where departments 101 and 321 are descendants of Dept_TotRD

3 REPLIES 3

JackLacava
Community Manager
Community Manager

If the number of such departments is low, the easiest approach is to have a number of Composite mappings that map A#yourAcc:U1#yourChildDept to a specific account. 

If that's not feasible, you will have to get dirty with a Complex Expression or Parser rule. You'll probably need args.GetSource or args.GetTarget to retrieve the UD member name, and BRApi.Finance.Members.IsChild (or .IsDescendant) to check if it's a child of your parent.

franciscoamores
Contributor II

If you want to take the api route, I’d recommend you have your rule getting all children of that parent the first time the rule is executed and save results in a collection  (you can achieve this using globals and storing all children in hashset).

then you just have to check if member is contained in the hashset.

in this way you avoid multiple api calls (one for each line matching the rule criteria and not mapped yet)

HTH

kustrup
New Contributor

Thank you for the responses! I was able to resolve the issue with an IF statement:

If BRApi.Finance.Members.IsDescendant(si, _
    BRApi.Finance.Dim.GetDimPk(si, "DIMENSION_NAME"), _
    BRApi.Finance.Members.GetMemberId(si, dimTypeID.UD3, "PARENT_MEMBER"), _
    BRApi.Finance.Members.GetMemberId(si, dimTypeID.UD3, DEPARTMENT_FOR_DATA_RECORD)) _
Then

 

That being said, it is definitely more efficient to use a global variable as franciscoamores said.