Forum Discussion

Marco's avatar
Marco
Contributor II
2 years ago

Currency Names

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.

  • 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()

     

  • JackLacava's avatar
    JackLacava
    Honored Contributor

    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()

     

    • Marco's avatar
      Marco
      Contributor II

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

      • JackLacava's avatar
        JackLacava
        Honored Contributor

        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.