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