Forum Discussion

kustrup's avatar
kustrup
New Contributor
2 years ago

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

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

  • kustrup's avatar
    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.

    • WernerN's avatar
      WernerN
      Contributor

      Was looking for something unrelated but your 'If Statement' inadvertently put me in the right direction.  Much appreciate you sharing your code. 

  • 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

  • JackLacava's avatar
    JackLacava
    Honored Contributor

    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.