Skip to main content
September 13, 2022

Delete Multiple Members using Extender Rule

  • September 13, 2022
  • 3 replies
  • 0 views

All - The below extender rule will be able to delete multiple member from Parent Hierarchy. 

1. Provide the Dimension Name & Top Parent Name in the Hierarchy - See highlighted in Red.

2. I want to make a point here the While Count > 3 because the it takes the current parent and other member ENtityDefault1 & None. Since we will not be able to delete it so it should be 3 or loop will be infinite. 

3. You can use as an input Variable for Dimension and Top Parent and attach to the dashboard but this is a good starting point.  


Dim dimensionPK As DimPk = BRApi.Finance.Dim.GetDimPk(si,"Dimension")
Dim nValue As Integer = BRApi.Finance.Members.GetMemberId(si, dimensionPK.DimTypeId,"TopParentName")

Dim objList1 As List(Of Member) = BRApi.Finance.Members.GetAllMembers(si,dimensionPK,nValue)
Dim objList2 As List(Of Member) = BRApi.Finance.Members.GetBaseMembers(si,dimensionPK,nValue)

Dim mbrct As Integer = objList1.Count

While mbrct > 3

For Each mbrbe As Member In objList2

If mbrbe.Name <> "None" Then
BRApi.Finance.MemberAdmin.RemoveMember(si, dimensionPK, mbrbe.MemberPk)

End If
Next
objList1 = BRApi.Finance.Members.GetAllMembers(si,dimensionPK,nValue)
objList2 = BRApi.Finance.Members.GetBaseMembers(si,dimensionPK,nValue)
mbrct = objList1.Count

End While

3 replies

September 23, 2022

Hey Krishna, thanks so much for the contribution!

As a quick tip for the future, you can get better formatting for code by expanding the toolbar

JackLacava_0-1663925708103.png

and then selecting the Code option

JackLacava_1-1663925732350.png

On the code itself, I suspect there might be a way to do this that would make fewer calls and wouldn't rely on checking the number of members left...

KrishnaAuthor
September 23, 2022

Thanks Jack for the feedback. I will make sure next time.

October 20, 2022

I built a similar BR recently and it is taking about ten seconds to delete each member.  Is that normal? I am using a Delete instead of a Remove.

KrishnaAuthor
October 20, 2022

It should not take 10's. Did you try with remove option?

October 21, 2022

I did not try Remove because I assumed it would just orphan the member. I need to really Delete the member because I am deleting the entire dimension.  I am adding dimensions and then deleting them until i get everything right. Do you know if Remove does the same thing as Delete or does Remove orphan the member?

July 12, 2023

Hi all

I'm using the BRApi.Finance.MemberAdmin.RemoveMember to remove a UD4 member which works well.

I was wondering if you had any suggestions on what the best way to check on whether there is information stored against the member is?

i.e. is there a built in function or do I need to do a get data cell formula

Thanks,

Mark

July 13, 2023

I came up with the following solution, which seemed to be the simplest:

Dim d As [Dim] = BRApi.Finance.Dim.GetDim(si, "UDDimension")
Dim m As Member = BRApi.Finance.Members.GetMember(si, d.DimPk.DimTypeId, xfRow.OriginalDataRow("MemberName"))
Dim sql As String = "SELECT TOP 1 * FROM vDataRecordAll Where UD4Id = '" & m.MemberId & "'"
Dim dt As DataTable = BRApi.Database.ExecuteSql(dbConn, sql, False)

If dt.Rows.Count <> 1 Then
	BRApi.Finance.MemberAdmin.RemoveMember(si, d.DimPk, m.MemberPk)
End If

 

July 13, 2023

I think that should do, although in theory you might want to check one of the Stage views too, on the target columns.