09-13-2022 02:29 PM - last edited on 05-02-2023 10:53 AM by JackLacava
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
09-23-2022 05:48 AM
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
and then selecting the Code option
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...
09-23-2022 07:01 AM
Thanks Jack for the feedback. I will make sure next time.
10-20-2022 03:22 PM
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.
10-20-2022 03:42 PM
It should not take 10's. Did you try with remove option?
10-21-2022 10:35 AM
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?
10-21-2022 10:39 AM
I sure it will not go to Orphan. I tried it.
10-21-2022 11:04 AM
Thank you. I'll try Remove. That would be great if that speeds up the process. Have a great day!
07-12-2023 10:04 AM
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
07-13-2023 02:09 AM
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
07-13-2023 04:55 AM
I think that should do, although in theory you might want to check one of the Stage views too, on the target columns.