locked
Business Rule on top parent of a hierarchy RRS feed

  • Question

  • Hi

    I have a request from my Client to set a attribute to be the top hierachy member of the current members parent.

    example hierarchy

    Root
      New Zealand
      Australia
        NSW
           Sydney
                  2000
                  2001
                  2605
           NewCastle
           Woolongong
        VIC
           Melbourne
                  3000
                  3001
           Sale
           Mildura

    where you have the member

    2000 has parent of Sydney and top parent of Australia (one benith root)

     

    By default when the Business Rule is run they want to set the top parent to be the correct member.

    I have a feeling the only way to do this is it to trigger a workflow that has SQL to update the Top Location ID.

    Any other thoughts would be appreciated.

    Cheers
    Tamzyn


    Tamzyn!
    Wednesday, August 24, 2011 1:55 AM

Answers

  • Hi Tamzyn,

    You can create business rules to "inherit" attribute values in a hierarchy.  If this is an explicit hierarchy, you would create a TopParent attribute for both consolidated and leaf members and then create 3 business rules: 2 for consolidated members and 1 for leaf members.  One of the consolidated rules would check if the parent is "Root" and if so, it would set the TopParent attribute value as that member's Code (or Name if desired).  The second consolidated rule would check if the parent is NOT "Root" and in that case it will inherit the TopParent attribute from it's parent member.  Then the leaf member rule would just inherit the TopParent attribute from it's parent's TopParent attribute value.  The rules are described below.

    Note: create the consolidated rules in the priority order show below.

     

     Rule 1: Consolidated Rule:  


          If Parent.HierarchyName.Code is not equal to Root

                Then
                        TopParent equals Parent.HierarchyName.TopParent


     Rule 2: Consoldated Rule:
     
           If Parent.HierarchyName.Code is equal to Root

               Then
                       TopParent equals Code


      
     Rule 3: Leaf Rule: 
     
          Actions:
               TopParent equals Parent.HierarchyName.TopParent


    If your hierarchy is a derived hierarchy, you would use a similar approach with a TopParent attribute in each entity and business rules at each level, but you would not need to check for "Root" since you would be defining the rules at each level.

     

    Note that you may not want to duplicate data in this way if you just need to provide the top parent value to a subscribing system.  You could just export the relationship via a subscription view.  The Levels subscription view for the hierarchy will provide this relationship without having to maintain specific attribute values in the model.


    Regards,
    Pam Matthews

    www.profisee.com




    • Proposed as answer by Pam Matthews Wednesday, August 31, 2011 12:25 AM
    • Marked as answer by Challen Fu Thursday, September 1, 2011 10:37 AM
    Thursday, August 25, 2011 4:37 PM

All replies

  • Hi Tamzyn,

    You can create business rules to "inherit" attribute values in a hierarchy.  If this is an explicit hierarchy, you would create a TopParent attribute for both consolidated and leaf members and then create 3 business rules: 2 for consolidated members and 1 for leaf members.  One of the consolidated rules would check if the parent is "Root" and if so, it would set the TopParent attribute value as that member's Code (or Name if desired).  The second consolidated rule would check if the parent is NOT "Root" and in that case it will inherit the TopParent attribute from it's parent member.  Then the leaf member rule would just inherit the TopParent attribute from it's parent's TopParent attribute value.  The rules are described below.

    Note: create the consolidated rules in the priority order show below.

     

     Rule 1: Consolidated Rule:  


          If Parent.HierarchyName.Code is not equal to Root

                Then
                        TopParent equals Parent.HierarchyName.TopParent


     Rule 2: Consoldated Rule:
     
           If Parent.HierarchyName.Code is equal to Root

               Then
                       TopParent equals Code


      
     Rule 3: Leaf Rule: 
     
          Actions:
               TopParent equals Parent.HierarchyName.TopParent


    If your hierarchy is a derived hierarchy, you would use a similar approach with a TopParent attribute in each entity and business rules at each level, but you would not need to check for "Root" since you would be defining the rules at each level.

     

    Note that you may not want to duplicate data in this way if you just need to provide the top parent value to a subscribing system.  You could just export the relationship via a subscription view.  The Levels subscription view for the hierarchy will provide this relationship without having to maintain specific attribute values in the model.


    Regards,
    Pam Matthews

    www.profisee.com




    • Proposed as answer by Pam Matthews Wednesday, August 31, 2011 12:25 AM
    • Marked as answer by Challen Fu Thursday, September 1, 2011 10:37 AM
    Thursday, August 25, 2011 4:37 PM
  • Thanks Pam.

    this was very useful.

    It is a dervived Heirachy. I'm not sure if the client will like the extra data.

    BUT the subscription view could be the way to go.

    Cheers

    Tamzyn


    Tamzyn!
    Monday, September 5, 2011 1:26 AM