You need to sign in to do that
Don't have an account?
Federico Larsen
DML not allowed on DatedConversionRate
Hi I am writing an Apex Class that updates the currencys exchange rates and I get this error:
DML not allowed on DatedConversionRate
I have seen apps, in javascript, and flex that updates the currencies, but why apex can NOT?
best regards
Hmm.. It might not be allowed outright from apex, but just in case, have you read through this:
http://developinthecloud.wordpress.com/2009/11/23/dml-currently-not-allowed/
Wes
hey wez, thanks for your response, but, I need to do it with scheduled apex code.
I read you article and add one dml error to your comments.
I don't understand why it is not posible to update it, but read it..... and you can update it trought the soap-api
weird
thanks anyways
Create a Connected App
Create an Auth. Providers
Create a Named credentials.
Step by Step instruction is given in the below two URLs.
http://www.jitendrazaa.com/blog/salesforce/salesforce-to-salesforce-integration-using-named-credentials-in-just-5-lines-of-code/
https://www.jitendrazaa.com/blog/salesforce/login-to-salesforce-from-salesforce-using-authentication-provider/#more-4516
Once the above configuration is done, please use the below piece of code to update the Managed Dated Currency.
HttpRequest feedRequest = new HttpRequest();
feedRequest.setEndpoint('callout{Named_Credentials}/services/data/v36.0/sobjects/DatedConversionRate/'+ {idDatedConversion} +'?_HttpMethod=PATCH');
feedRequest.setBody('{ "ConversionRate" : '+ {rate }+' }');//Rate to be updated
feedRequest.setHeader('Content-Type', 'application/json');
feedRequest.setMethod('POST');
Http http = new Http();
try
{
if(!Test.isRunningTest()){
HTTPResponse feedResponse = http.send(feedRequest);
}
}
catch(Exception ex)
{
System.debug('exception in BatchCurrecnyCovnersionUpdate.execute method '+ex.getMessage());
}