01-17-2022 05:44 AM - last edited on 05-02-2023 10:54 AM by JackLacava
Hi all
Onestream stores a lot of information using an integer ID instead of a name. And most of the time we also deliver a simple way, to get objects (or names of objects) using an api or brapi call.
Somehow getting the name of a dimension from its ID is an exception. Is there a simple way to do it?
Cheers
Solved! Go to Solution.
01-17-2022 05:46 AM
I came up with some simple code to do so, do you know even simpler once?
BRAPI:
Dim aDimID As Integer = 0
Dim aDimName As String = BRApi.Finance.Dim.GetDim(si, New DimPk(dimtypeid.Scenario, aDimID)).Name
brapi.ErrorLog.LogMessage(si, $"Name {aDimName}")
aDimName = ""
aDimName = brapi.Finance.Dim.GetDims(si, dimtypeid.Scenario).Find(Function(x) x.DimPk.DimId = aDimID).Name
brapi.ErrorLog.LogMessage(si, $"Name {aDimName}")
and
Api:
Dim aDimID As Integer = 0
Dim aDimName As String = api.Dimensions.GetDim(New DimPk(dimtypeid.Scenario, aDimID)).Name
brapi.ErrorLog.LogMessage(si, $"Name {aDimName}")
aDimName = ""
aDimName = api.Dimensions.GetDims(dimtypeid.Scenario).Find(Function(x) x.DimPk.DimId = aDimID).Name
brapi.ErrorLog.LogMessage(si, $"Name {aDimName}")
Cheers
01-17-2022 05:46 AM
I came up with some simple code to do so, do you know even simpler once?
BRAPI:
Dim aDimID As Integer = 0
Dim aDimName As String = BRApi.Finance.Dim.GetDim(si, New DimPk(dimtypeid.Scenario, aDimID)).Name
brapi.ErrorLog.LogMessage(si, $"Name {aDimName}")
aDimName = ""
aDimName = brapi.Finance.Dim.GetDims(si, dimtypeid.Scenario).Find(Function(x) x.DimPk.DimId = aDimID).Name
brapi.ErrorLog.LogMessage(si, $"Name {aDimName}")
and
Api:
Dim aDimID As Integer = 0
Dim aDimName As String = api.Dimensions.GetDim(New DimPk(dimtypeid.Scenario, aDimID)).Name
brapi.ErrorLog.LogMessage(si, $"Name {aDimName}")
aDimName = ""
aDimName = api.Dimensions.GetDims(dimtypeid.Scenario).Find(Function(x) x.DimPk.DimId = aDimID).Name
brapi.ErrorLog.LogMessage(si, $"Name {aDimName}")
Cheers
01-17-2022 05:57 AM
Getting DimPk works the same, here one sample:
Dim aDimID As Integer = 0
Dim aDimPK As Dimpk = api.Dimensions.GetDim(New DimPk(dimtypeid.Scenario, aDimID)).DimPk
aDimPK = api.Dimensions.GetDims(dimtypeid.Scenario).Find(Function(x) x.DimPk.DimId = aDimID).DimPk
01-24-2022 12:54 PM
Hi Christian!
To return names of the dimensions this is what I figured out:
Dim DimName As String = OneStream.Shared.Common.MemberType.GetName(GetType(MemberType), DimTypeId)
Hernan
01-29-2022 05:06 AM
Hi Hernan
Very interesting code sample, I will need to invest some more time in it, but unfortunately, it doesn't give back the dimension name but the DimType's name.
Thanks and cheers
Christian