I Would like to print the Parent Dimension Member in error log
- 3 months ago
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.
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
You can see under Finance.Members there is a GetParents function (the others are related to workflows).
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