+ Start a Discussion
Federico LarsenFederico 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:





Federico LarsenFederico Larsen

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




thanks anyways 

you can also try the below to update currency. . 
Create a Connected App
Create an Auth. Providers
Create a Named credentials.
Step by Step instruction is given in the below two URLs.

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');
        Http http = new Http();
                HTTPResponse feedResponse = http.send(feedRequest);
        catch(Exception ex)
            System.debug('exception in BatchCurrecnyCovnersionUpdate.execute method '+ex.getMessage());