Forum Discussion

NidhiMangtani's avatar
NidhiMangtani
Contributor III
3 years ago

Specifying SiblingSortOrder while adding relationship through extensibility rule

Hello,

Can we figure out sibling sort order for existing members and add the new members at a specific position in hierarchy through extensibility rule?

Any samples would be helpful.

  • Dim relationshipPositionOptions As New RelationshipPositionOptions
    relationshipPositionOptions.SiblingId = sSiblingID
    relationshipPositionOptions.MovementType = RelationshipMovementType.InsertBeforeSibling

    BRApi.Finance.MemberAdmin.SaveRelationshipInfo(si, relationshipInfo, relationshipPositionOptions)

    Specifying movementtype worked.

    No assistance needed.

  • Dim relationshipPositionOptions As New RelationshipPositionOptions
    relationshipPositionOptions.SiblingId = sSiblingID
    relationshipPositionOptions.MovementType = RelationshipMovementType.InsertBeforeSibling

    BRApi.Finance.MemberAdmin.SaveRelationshipInfo(si, relationshipInfo, relationshipPositionOptions)

    Specifying movementtype worked.

    No assistance needed.

  • JennyCalvache's avatar
    JennyCalvache
    New Contributor III

    Hello,

    I think I may figure it out. Below is my working codes.

    'Try to move Myaccountname position to before SiblingName
    Dim parentMem As MemberInfo = BRApi.Finance.Metadata.GetMember(si, DimType.Account.Id, ParentName)
    Dim siblingMem As MemberInfo = BRApi.Finance.Metadata.GetMember(si, DimType.Account.Id, SiblingName)
    Dim myMember As MemberInfo = BRApi.Finance.Metadata.GetMember(si, DimType.Account.Id, Myaccountname)
     
    'retrieve rel info for parent child relationship
    Dim myRelInfo As RelationshipInfo = BRApi.Finance.Members.GetRelationshipInfo(si, dimTypeId.Account, Myaccountname, ParentName)
     
    Dim newProperties As New VaryingMemberProperties( DimType.Account.id, mymember.Member.MemberId, parentmem.Member.MemberId )
     
    'reset the position
    Dim relationPosOpts As New RelationshipPositionOptions()
    relationPosOpts.SiblingId = siblingMem.Member.MemberId
    relationPosOpts.MovementType = RelationshipMovementType.InsertBeforeSibling
     
    'save the relationship info and update the ownership property
    BRApi.Finance.MemberAdmin.SaveRelationshipInfo(si, True, myRelInfo.Relationship,True, newProperties, relationPosOpts)
  • JennyCalvache's avatar
    JennyCalvache
    New Contributor III

    Hello, 

    I tried to move a account from one position to another position within same parent group.

    Tried to modify using the codes above but no luck. Below is my code and any help will be appreciated.

     

    'Try to move Myaccountname position to before SiblingName
    Dim parentMem As MemberInfo = BRApi.Finance.Metadata.GetMember(si, DimType.Account.Id, "ParentName")
    Dim siblingMem As MemberInfo = BRApi.Finance.Metadata.GetMember(si, DimType.Account.Id, "SiblingName")
    Dim myMember As MemberInfo = BRApi.Finance.Metadata.GetMember(si, DimType.Account.Id, "MyAccountName")
     
    'Relationship
    Dim relationshipInfo As New RelationshipInfo
      Dim relationship As New Relationship
      Dim relationshipPK As New RelationshipPk
      relationshipPK.ParentId = parentMem.Member.MemberId
      relationshipPK.ChildId = myMem.Member.MemberId  
     
      relationship.RelationshipPk = relationshipPK
      relationshipInfo.Relationship = relationship
     
      Dim relationshipPositionOptions As New RelationshipPositionOptions
      relationshipPositionOptions.SiblingId = siblingMem.Member.MemberId   
      relationshipPositionOptions.MovementType = RelationshipMovementType.InsertBeforeSibling
     
      BRApi.Finance.MemberAdmin.SaveRelationshipInfo(si, relationshipInfo, relationshipPositionOptions)
     
    Thank you!