Forum Discussion

sonuanand's avatar
sonuanand
New Contributor
3 days ago
Solved

Select Currency Property for Entity Member

While building the hierarchy using codes, In the Entity Dimension hierarchy "EntityH1", I have a base member as "MyBase". Below code is successfully creating a new child member as "T2" under Parent "MyBase".

I am able to set the Text1 property. Can please some one help to suggest how to set Currency property to select a particular currency (Let's take "SGD")

'Set the Dimension Type as Entity

Dim objMemberPk As New MemberPk(DimType.Entity.Id, DimConstants.Unknown)

'Update Dim Name accordingly

Dim objDim As OneStream.Shared.Wcf.Dim = BRApi.Finance.Dim.GetDim(si, "EntityH1")

'Create New Member

Dim objMember As New Member(objMemberPk, "T2", "T2 Entities", objDim.DimPk.DimId)

'Create VaryingMemberProperties object

Dim objProperties As New VaryingMemberProperties(objMemberPk.DimTypeId, objMemberPk.MemberId, DimConstants.Unknown)

'Create new member info object for new member

Dim objMemberInfo As New MemberInfo(objMember, objProperties, Nothing, objDim, DimConstants.Unknown)

'Modify some member properties. Entity dimension, in this example.

Dim entityProperties As EntityVMProperties = objMemberInfo.GetEntityProperties()

entityProperties.Text1.SetStoredValue(ScenarioType.Unknown.Id, DimConstants.Unknown, "Test Entity Text1")

'Save the member and its properties.

Dim isNew As TriStateBool = TriStateBool.TrueValue

BRApi.Finance.MemberAdmin.SaveMemberInfo(si, objMemberInfo, True, True, False, isNew)

objMember = BRApi.Finance.Members.ReadMemberNoCache(si, objMemberPk.DimTypeId, "T2")

'Create Parent Child Relationship

Dim rowParentID As String = BRApi.Finance.Members.GetMemberId(si, objMemberPk.DimTypeId, "MyBase")

Dim relToCreatePk As New RelationshipPk(objMemberPk.DimTypeId, rowParentID, objMember.MemberId)

Dim relToCreate As New Relationship(relToCreatePk, objMember.DimId, RelationshipMovementType.InsertAsLastSibling, 1)

Dim relToCreateInfo As New RelationshipInfo(relToCreate, Nothing)

Dim relPostionOpt As New RelationshipPositionOptions(RelationshipMovementType.InsertAsLastSibling, 1)

brapi.Finance.MemberAdmin.SaveRelationshipInfo(si, relToCreateInfo, relPostionOpt)

  • Found the currency code in FX tables (dbo.FxRate). To automate, can create a list/ array and map the currency with the code.

    Sample Code:

    entityProperties.Currency.SetStoredValue(122)

1 Reply

  • sonuanand's avatar
    sonuanand
    New Contributor

    Found the currency code in FX tables (dbo.FxRate). To automate, can create a list/ array and map the currency with the code.

    Sample Code:

    entityProperties.Currency.SetStoredValue(122)