cancel
Showing results for 
Search instead for 
Did you mean: 

How do I get a dim name (dimpk) from a dim ID?

ChristianW
OneStream Employee
OneStream Employee

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

 

1 ACCEPTED SOLUTION

ChristianW
OneStream Employee
OneStream Employee

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

View solution in original post

4 REPLIES 4

ChristianW
OneStream Employee
OneStream Employee

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

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

Hernan_Carvi
New Contributor

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

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