Hi Diane
Yes, it is possible, this sample will do what you described.
You can run it in any business rule type. I tested it in an Extender business rule, you can call it using a Data Management Job and/or schedule it to run every month using Task Scheduler. In these cases, you should not pick the actual period from the user interface, but pass a parameter.
In the sample, I didn't test if I might override an existing exchange rate, please be careful to avoid unexpected results.
Dim actualPeriod As String = TimeDimHelper.GetNameFromId(si.WorkflowClusterPk.TimeKey)
Dim previousPeriod As String = TimeDimHelper.GetNameFromId(TimeDimHelper.GetPriorPeriod(si.WorkflowClusterPk.TimeKey, True))
For Each sourceCurrency As Currency In Currency.GetItems
For Each targetCurrency As Currency In Currency.GetItems
Dim fxRatePkUsingNames As New FxRatePkUsingNames("ClosingRate", previousPeriod, sourceCurrency.Name, targetCurrency.Name)
Dim objFxRateUsingNames As FxRateUsingNames = BRApi.Finance.Data.GetStoredFxRate(si, fxRatePkUsingNames)
If objFxRateUsingNames.Amount > 0 Then
Dim fxTargetRatePkUsingNames As New FxRatePkUsingNames("AverageRate", actualPeriod, sourceCurrency.Name, targetCurrency.Name)
Dim objFxTargetRateUsingNames As New FxRateUsingNames(fxTargetRatePkUsingNames, objFxRateUsingNames.Amount)
Dim objXFResult As XFResult = BRApi.Finance.Data.SetFxRate(si, objFxTargetRateUsingNames)
End If
Next
Next
I hope this helps and kind regards
Christian