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

NicolasArgente
Valued Contributor

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 ! 

Connect with me on:
LinkedIn: https://www.linkedin.com/in/nicolas-argente/
Website: https://aiqos.io
If you want to lift yourself up, lift up someone else.
8 REPLIES 8

NicolasArgente
Valued Contributor

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!

Connect with me on:
LinkedIn: https://www.linkedin.com/in/nicolas-argente/
Website: https://aiqos.io
If you want to lift yourself up, lift up someone else.

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.

Perfect. Thanks

Connect with me on:
LinkedIn: https://www.linkedin.com/in/nicolas-argente/
Website: https://aiqos.io
If you want to lift yourself up, lift up someone else.

Hi @ckattookaran 

Can you please develop on this? I had a look at the PDF api and cannot find any info. Neither on KB nor Community.
The only info I find is in below. Have you got a sample to share with us? Thanks

 

Dim si As _-_0_-_
Dim xml As _-_1_-_
Dim zipFileBytes() As _-_2_-_
Dim fileName As _-_3_-_
Dim systemXmlFileType As SystemXmlFileType
Dim applicationXmlFileType As ApplicationXmlFileType
Dim options As XmlLoadOptions
Dim value As TaskActivityItem


value = _-_4_-_.StartLoadXml(si, xml, zipFileBytes, fileName, systemXmlFileType, applicationXmlFileType, options)

Connect with me on:
LinkedIn: https://www.linkedin.com/in/nicolas-argente/
Website: https://aiqos.io
If you want to lift yourself up, lift up someone else.

Dim backgroundTask As TaskActivityItem = Nothing
				ZipFile.CreateFromDirectory($"{strRuleLocation}", $"{strRuleLocation.Replace("Directory","")}\Rules.zip")
				Dim bZipRules As Byte() = File.ReadAllBytes($"{strRuleLocation.Replace("Directory","")}\Rules.zip")
				
				'Execute the load as a Background Task
				backgroundTask = XmlLoadWcf.StartLoadXml(si, "",  bZipRules, "Rules.zip", SystemXmlFileType.Unknown, ApplicationXmlFileType.ApplicationZipFile, Nothing)
				

This is a rule I'm using to Zip multiple XMLs and load them. The XML option (2nd parameter) is the XML string (if you are using one XML. The 3rd one is useful if you are loading a zip file (a package). If you are loading an Application XML, then you can set the SystemXMLFileType to Unknown. I've not used XMLLoadOptions.

Thanks. I will investigate that. For now I took the easy road with the ZIP.

Connect with me on:
LinkedIn: https://www.linkedin.com/in/nicolas-argente/
Website: https://aiqos.io
If you want to lift yourself up, lift up someone else.

JennyCalvache
New Contributor III

Hello,

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

Thanks!

JennyCalvache
New Contributor III

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