Forum Discussion

OSAdmin's avatar
OSAdmin
Valued Contributor
5 years ago

Does anybody know how I reference FX rates in a Dashboard XFBR String rule?

Originally posted by Charlie Griffiths

6/27/2019

Does anybody know how I reference FX rates in a Dashboard XFBR String rule? I need to perform some FX conversions within a Reporting Compliance solution. Thanks.

  • OSAdmin's avatar
    OSAdmin
    Valued Contributor
    Originally posted by Nick Kroppe

    you're unfortunately not going to have API's available to you in a BR string (only BRAPIs are available) so the above is not going to work. There are several ways to get at the FX rates, I will post two ways I've done it in a BR string before.
    'Get rate type, time period, source And destination currencies
    Dim objFxRatePkUsingNames As New FxRatePkUsingNames(""AverageRate"",""2018m1"",""EUR"",""USD"")

    'Get the rate
    Dim fxRate As Decimal = brapi.Finance.Data.GetCalculatedFxRate(si,currencyId.EUR,objFxRatePkUsingNames)

    'Get WFTime Name
    Dim timeName As String = BRApi.Finance.Members.GetMember(si, dimTypeId.Time, timeKey).Name
    'Get FX Rate Type defined in RCM settings - this will be the rate type used to translate
    Dim fxRateType As String = BRApi.Dashboards.Parameters.GetLiteralParameterValue(si,False,""StoredFXRateType_RCMT"")
    'Get application currency defined in RCM settings - this will be the source currency
    Dim sourceCurrency As String = BRApi.Dashboards.Parameters.GetLiteralParameterValue(si,False,""StoredFXAppCurrency_RCMT"")
    Dim translatedUnexplainedLimit As Decimal = Nothing
    'Get FX rates info
    Dim objFxRatePkUsingNames As New FxRatePkUsingNames(fxRateType, timeName, sourceCurrency, destinationCurrency)
    Dim objFxRateUsingNames As FxRateUsingNames = BRApi.Finance.Data.GetStoredFxRate(si, objFxRatePkUsingNames)

    'for USD currencies, return the natural unexplained limit. For other currencies, translate the unexplained limit to local currency
    If destinationCurrency.XFEqualsIgnoreCase(""USD"") Then

    Return varUnexplainedLimit

    Else

    'confirm there is an FX rate, retrieve the rate and calculate the translated amt
    If Not objFxRateUsingNames Is Nothing Then

    Dim varFXRate As Decimal = objFxRateUsingNames.Amount