Skip to main content
Veteran
Jan 16, 2023 10:24 PM UTC

How to delete all relationships of a TOP dimension member? (or orphans all members below a TOP mb)

Hi there,

I have a dimension with 10 000 members under a TOP member.
I can delete all of the relationships below TOP running :
  BRApi.Finance.MemberAdmin.RemoveRelationships
However, it is extremely slow as it does it one by one, so it takes hours.
The same thing with the XML load is a load faster.
  <relationship parent="TOPTOP" child="XXXX" action="Delete" />

Any BR to upload the XML or other clever ideas?

Thanks One Team ! 

8 replies

Veteran
Jan 17, 2023 10:27 AM UTC

OK got it solved using the BR. It runs fast now. I made a mistake... 🙂

I still would be interested if someone ever load an XML of metadata from a BR. Thanks Team!

Member
Jan 17, 2023 4:53 PM UTC

Try using XmlLoadWcf.StartLoadXml, you need to provide either supply the XML content as a string or if it is zipfile then provide the bytes of the zip, then the type of ApplicationXmlFileType.

Veteran
Jan 19, 2023 10:46 AM UTC

Perfect. Thanks

Newcomer
Feb 26, 2024 5:09 PM UTC

Hello,

Do you have any working codes to removeRelationships from an account group such as "Expense"?

Thanks!

Newcomer
Feb 28, 2024 1:44 PM UTC

I think I figure it out.

Dim ParentGroup As String = args.NameValuePairs.XFGetValue("ParentGroup")
 
Dim osAccountMember As Member = BRApi.Finance.Members.GetMember(si, dimtypeid.Account, ParentGroup)
Dim actDimPk As DimPk = BRApi.Finance.Dim.GetDimPk(si, "ST_Accounts")
Dim osBaseList As list(Of Member) = BRApi.Finance.Members.GetChildren(si, actDimPk, osAccountMember.MemberId)
For Each baseMember As Member In osBaseList'osBaseList
'===Remove first====
Dim PId As Integer = BRApi.Finance.Members.GetMemberId(si, dimTypeId.Account, osAccountMember.Name)
Dim myId As Integer = BRApi.Finance.Members.GetMemberId(si, dimTypeId.Account, baseMember.Name)
Dim relationshipPks As New List(Of RelationshipPk)
Dim RelPk As New RelationshipPk(actDimPk.DimTypeId, PId, myId)
relationshipPks.Add(RelPk)
 
BRApi.Finance.MemberAdmin.RemoveRelationships(si, actDimPk, relationshipPks, True)
 
Next