06-21-2022 06:55 AM - last edited on 05-02-2023 10:10 AM by JackLacava
Hello,
Please share a reference for adding a relationship between dimension members via Extender rule. I am trying to add new members via Extender rule, the member gets added as an Orphan.
I have tried using SaveRelationshipInfo by passing Parent Member ID, Sibling ID and the new member ID, The IDs being passed are correct, but still the new member gets added as an Orphan.
Current code which I am trying for adding relationship:
Public Sub AddRelationForNewCurrentRate(ByVal si As SessionInfo, ByVal api As Object, ByVal objPriorMemberInfo As MemberInfo)
Try
Dim objUtil As New OneStream.BusinessRule.Extender.EQUIP_Utility_Helper.MainClass(si)
Dim sParentMemberID As String = String.Empty
Dim sNewMemberID As String = String.Empty
'Get Parent
Dim objParentMemberInfo As List(Of MemberInfo) = BRApi.Finance.Metadata.GetMembersUsingFilter(si, "RevSummaryAccounts", "A#[" & Sibling & "].Parents", True)
If Not IsNothing(objParentMemberInfo) AndAlso objParentMemberInfo.Count > 0 Then
sParentMemberID = objParentMemberInfo(0).Member.MemberId
End If
'Get New Member
Dim objNewMemberInfo As List(Of MemberInfo) = BRApi.Finance.Metadata.GetMembersUsingFilter(si, "RevSummaryAccounts", "A#[" & NewMember & "]", True)
If Not IsNothing(objNewMemberInfo) AndAlso objNewMemberInfo.Count > 0 Then
sNewMemberID = objNewMemberInfo(0).Member.MemberId
BRapi.ErrorLog.LogMessage(si, "Child ID: " & sNewMemberID)
End If
Dim relationshipInfo As New RelationshipInfo
Dim relationship As New Relationship
Dim relationshipPK As New RelationshipPk
relationshipPK.ParentId = sParentMemberID
relationshipPK.ChildId = sNewMemberID
relationship.RelationshipPk = relationshipPK
relationshipInfo.Relationship = relationship
Dim relationshipPositionOptions As New RelationshipPositionOptions
relationshipPositionOptions.SiblingId = objPriorMemberInfo.Member.MemberId
' BRapi.ErrorLog.LogMessage(si, "Child ID: " & relationshipInfo.Relationship.RelationshipPk.ChildId)
BRapi.ErrorLog.LogMessage(si, "Parent ID: " & sParentMemberID)
BRapi.ErrorLog.LogMessage(si, "Sibling ID: " & objPriorMemberInfo.Member.MemberId)
BRApi.Finance.MemberAdmin.SaveRelationshipInfo(si, relationshipInfo, relationshipPositionOptions)
Catch ex As Exception
Throw ErrorHandler.LogWrite(si, New XFException(si, ex))
End Try
End Sub
Solved! Go to Solution.
06-21-2022 07:11 AM
Additionally passed DimID, DimTypeID and UD Aggregation weight and it worked as expected. No action needed on this further.
06-21-2022 07:11 AM
Additionally passed DimID, DimTypeID and UD Aggregation weight and it worked as expected. No action needed on this further.
10-25-2022 08:17 PM
Thank you for the post Nidhi, I had the same problem where the member was created but as an orphan.
For reference, I found it is the relationship variable you need to set the DimId and UD Aggregation for:
Dim relationship As New Relationship
Dim objDim As OneStream.Shared.Wcf.Dim = BRApi.Finance.Dim.GetDim(si, "CorpEntities")
relationship.DimId = objDim.DimPk.DimId
relationship.UDAggWeight = 1
Regards,
Tom