web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

Session Id :
Microsoft Dynamics AX (Archived)

Exchange rate provider is invalid when try to run exchange rate import in a batch job

(0) ShareShare
ReportReport
Posted on by 30

Hi.

After follow the whitepapers of Microsoft to create a customer exchange rate currency provider, everythings works fine if i run the process manually in General Ledger to import the currency rate.

But the problem appears when i put this task to run into a batch job, the register section give me this error 

Microsoft.Dynamics.Ax.Xpp.ErrorException: Se produjo una excepción de tipo 'Microsoft.Dynamics.Ax.Xpp.ErrorException'.
en Dynamics.Ax.Application.ExchangeRateImportOperation.Import(ExchangeRateImportRequest exchangeRateImportRequest) en ExchangeRateImportOperation.import.xpp:línea 31
en ExchangeRateImportOperation::import(Object , Object[] )
en Microsoft.Dynamics.Ax.Xpp.ReflectionCallHelper.MakeInstanceCall(Object instance, String MethodName, Object[] parameters)
en Dynamics.Ax.Application.SysOperationServiceController.Runoperation(Boolean _async) en SysOperationServiceController.runOperation.xpp:línea 88
en Dynamics.Ax.Application.SysOperationServiceController.Run() en SysOperationServiceController.run.xpp:línea 27
en Dynamics.Ax.Application.BatchRun.runJobStaticCode(Int64 batchId) en BatchRun.runJobStaticCode.xpp:línea 54
en Dynamics.Ax.Application.BatchRun.runJobStatic(Int64 batchId) en BatchRun.runJobStatic.xpp:línea 13
en BatchRun::runJobStatic(Object[] )
en Microsoft.Dynamics.Ax.Xpp.ReflectionCallHelper.MakeStaticCall(Type type, String MethodName, Object[] parameters)
en BatchIL.taskThreadEntry(Object threadArg)

 


I don't have any ideas to see where it's the problem.

Here it's my code to process the exchange rate

public ExchangeRateResponse getExchangeRates(ExchangeRateRequest _exchangeRateRequest)
{
ExchangeRateResponse _response;
ExchangeRateResponseExchangeRate _exchangeRateResponse;
ExchangeRateResponseCurrencyPair _currencyPairResponse;
ExchangeRateRequestCurrencyPair _currencyPairRequest;
ExchangeRateProviderConfig _config;
System.Exception _netExcepn;
ValidFromDate _exchangeDate;
RetailCommonWebAPI _webApi;
RetailWebRequest _request;
RetailWebResponse _responseUrl;
CurrencyExchangeRate _exchangeRate;
Array _resultJson;

int _cycle;
str _requestString;
str _srvUrl;
str _currencies;
str _sourceCurrency;
str _accessToken;
str _result;
str _key;
anytype _current;
container _content;
str _typeCurrency;
real _usddop;
real _usdeur;

_response = ExchangeRateResponse::construct();
_config = ExchangeRateProviderConfig::construct();
_srvUrl = _config.getPropertyValue(this.getProviderId(), #ServiceURL);
_accessToken = _config.getPropertyValue(this.getProviderId(), #AccessKey);
_currencies = _config.getPropertyValue(this.getProviderId(), #ListCurrencies);
_sourceCurrency = _config.getPropertyValue(this.getProviderId(), #BaseCurrency);
_requestString = strFmt(_srvUrl, _accessToken, _currencies, _sourceCurrency);

try
{
_webApi = RetailCommonWebAPI::construct();
_request = RetailWebRequest::newUrl(_requestString);
_responseUrl = _webApi.getResponse(_request);

// Parse the JSON to retrieve the rate.
_resultJson = JsonHelper::parseJson(_responseUrl.parmData());
_result = _resultJson.value(1);
_cycle = strscan(_result, 'USDDOP',1, strlen(_result));
_usddop = str2num(substr(_result,_cycle + 8, 9));
_cycle = strscan(_result, 'USDEUR',1, strlen(_result));
_usdeur = str2num(substr(_result,_cycle + 8, 9));
_exchangeRate = (100 * (_usdeur / _usddop));
_currencyPairRequest = _exchangeRateRequest.getCurrentCurrencyPair();
_currencyPairResponse = ExchangeRateResponseCurrencyPair::construct();

if(_currencyPairRequest == null)
{
_currencyPairRequest = ExchangeRateRequestCurrencyPair::construct();
_currencyPairRequest.parmFromCurrency("DOP");
_currencyPairRequest.parmToCurrency("EUR");
}

_currencyPairResponse.parmFromCurrency(_currencyPairRequest.parmFromCurrency());
_currencyPairResponse.parmToCurrency(_currencyPairRequest.parmToCurrency());
_currencyPairResponse.parmExchangeRateDisplayFactor(ExchangeRateDisplayFactor::Hundred);

_exchangeRateResponse = ExchangeRateResponseExchangeRate::construct();
_exchangeDate = System.DateTime::Parse(DateTimeUtil::toStr(DateTimeUtil::utcNow()),
System.Globalization.CultureInfo::get_CurrentUICulture(),
System.Globalization.DateTimeStyles::AssumeUniversal);
_exchangeRateResponse.parmValidFrom(_exchangeDate);
_exchangeRateResponse.parmExchangeRate(_exchangeRate);
_currencyPairResponse.addExchangeRate(_exchangeRateResponse);
_response.addOrUpdateCurrencyPair(_currencyPairResponse);
}
catch(Exception::CLRError)
{
_netExcepn = CLRInterop::getLastException();
info(_netExcepn.ToString());
}
return _response;
}

The AX version is 2012 R3 CU8

Regards

Eduardo Rotundo

*This post is locked for comments

I have the same question (0)
  • Eduardo Rotundo Profile Picture
    30 on at

    Hi Sukrut!

    I generated the CIL, the only detail in this process of generation the CIL it's i had to change the property runOn to Client first and after that restore to Call From

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Stars!

Meet the Microsoft Dynamics 365 Contact Center Champions

We are thrilled to have these Champions in our Community!

Congratulations to the March Top 10 Community Leaders

These are the community rock stars!

Leaderboard > 🔒一 Microsoft Dynamics AX (Archived)

#1
CP04-islander Profile Picture

CP04-islander 39

#2
Michel ROY Profile Picture

Michel ROY 14

#3
imran ul haq Profile Picture

imran ul haq 8

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans