I Would like to print the Parent Dimension Member in error log

NoorMohd
New Contributor

Hi All,

 

I need some assistance in printing the to dimensionally get the parent name of the Child member.

NoorMohd_0-1727088959005.png

Code populating the base member into the table is completed without any error.

Can someone please help.

 

Thanks 

 

3 REPLIES 3

DanielWillis
Contributor III

If you share your code, someone can tell you what's wrong / what you need to change.

NoorMohd
New Contributor

Thanks for your response.

NoorMohd_1-1727101033435.png

 

In the above code I have created a SQL table and Inserted the first column dynamically from get member using filter.

Now I would like to display the parent member of the of there respective in the second column.

Thanks  

Hi NoorMohd,

If you post your code with the code tags instead of screenshots it makes it a lot easier for people to help.

I'll show you how to get what you need but also how you can figure it out.

You have your member stored in 'items' each loop iteration (I would have called it 'item' rather than 'items' but that doesn't impact the code, just makes it easier to understand)

First thing to do is see if the items object has a function or property that has parent details. If you type 'items' followed by a '.' then it will bring up a list of these things.

DanielWillis_0-1727129546463.png

You can see that it has ParentMemberId there, so items.ParentMemberId would give you the ID of the parent. Now you just need to get the member name.

This is where you should jump into the snippet editor on the left of the code and just type in Parent

DanielWillis_1-1727129714934.png

You can see under Finance.Members there is a GetParents function (the others are related to workflows).

DanielWillis_2-1727129799586.png

Clicking on it gives some basic documentation. To be honest this is where it gets a bit tricky for a new developer because while it tells you what it can do it isn't particularly helpful on how to use these.

On the sample tab you can copy the code

objList = BRApi.Finance.Members.GetParents(si, dimPk, memberId, includeRootMemberInResult, dimDisplayOptions)

You would need to declare objList so would change this to

Dim objList As List(of Member) = BRApi.Finance.Members.GetParents(si, dimPk, memberId, includeRootMemberInResult, dimDisplayOptions)

Now, you asked for a parent but a member can actually have multiple parents. You would either need to change your logic to insert additional rows for each parent OR perhaps we can make the assumption in your case that each member only has a single parent in the hierarchy. I will make this assumption.

Dim parentList As List(Of Member) = BRApi.Finance.Members.GetParents(si, items.MemberDim.DimPk, items.ParentMemberId, False, Nothing)
Dim parent As String
If Not parentList Is Nothing AndAlso parentList.Count > 0
	parent = parentList(0).Name
Else 
	parent = "Parent Not Found"
End If

You can then update your query.

I haven't tested the above code but if it doesn't work you should be able to get the gist.

- Daniel