Currency Names

Marco
Contributor

Hi Everyone.

I am performing a conversion in a SQL query using currencies; I relied on this other post for now.

Where is stored the Currency Name ? 

The problem I have is that I have some SourceCurrencyId in the FXrates table that don't appear there, so I want to know if there's a way to get all possible currency names through a business rule.

1 ACCEPTED SOLUTION

JackLacava
Community Manager
Community Manager

To retrieve a Currency object from an ID:

Dim objCurrency As Currency = BRApi.Finance.Cons.GetCurrency(si, currencyId)
BRApi.ErrorLog.LogMessage(si, $"Name: {objCurrency.Name}")
BRApi.ErrorLog.LogMessage(si, $"Symbol: {objCurrency.Symbol}")
BRApi.ErrorLog.LogMessage(si, $"Desc: {objCurrency.DefaultDescription}")

To retrieve all Currency objects:

Dim allCurrencies as List(Of Currency) = Currency.GetItems()

 

View solution in original post

4 REPLIES 4

JackLacava
Community Manager
Community Manager

To retrieve a Currency object from an ID:

Dim objCurrency As Currency = BRApi.Finance.Cons.GetCurrency(si, currencyId)
BRApi.ErrorLog.LogMessage(si, $"Name: {objCurrency.Name}")
BRApi.ErrorLog.LogMessage(si, $"Symbol: {objCurrency.Symbol}")
BRApi.ErrorLog.LogMessage(si, $"Desc: {objCurrency.DefaultDescription}")

To retrieve all Currency objects:

Dim allCurrencies as List(Of Currency) = Currency.GetItems()

 

Thanks

This gave me all the currency names, but is there a way to get them along with their IDs?

JackLacava
Community Manager
Community Manager

Just loop on that allCurrencies, the objects have the Id property:

' in a custom calculate
Dim allCurrencies As List(Of Currency) = Currency.GetItems()
Dim sb As New System.Text.StringBuilder
For Each cur As Currency In allCurrencies
	sb.AppendLine($"{cur.Name} - {cur.Id}")
Next
api.LogMessage("Currencies", sb.ToString)
JackLacava_0-1701425707655.png

Btw, I would recommend to brush up on VB - trying to accomplish everything in OneStream with SQL increases complexity and sooner or later will hit a wall from a performance or maintenance perspective - or both.