11-30-2023 04:01 PM - last edited on 11-30-2023 04:39 PM by JackLacava
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.
Solved! Go to Solution.
11-30-2023 04:36 PM
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()
11-30-2023 04:36 PM
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()
11-30-2023 06:17 PM
Thanks
11-30-2023 06:33 PM
This gave me all the currency names, but is there a way to get them along with their IDs?
12-01-2023 05:12 AM - edited 12-01-2023 05:15 AM
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)
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.