function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
nagendra kumar 21nagendra kumar 21 

How to Write a scheduled class to update the Data Conversion Rate at the start of every month.

Hi All, 
please help me developing code or share code who to write apex class for this scenario and how to schedule it.

req - 
1) Fetch the exchange rate (CAN/USD) from some publicly available api using apex
2) Given this exchange rate create a Currency Conversion Record with the correct start date, end date and exchange rate.
3) Run a scheduled job to run (1) and (2) once per month.

Raj VakatiRaj Vakati
You can call the REst API​​​​​​​​​​​​​​​​​​​​​

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());

nagendra kumar 21nagendra kumar 21
Hi Raj, i actually dont understand how to use it,
can you help me setp by setp. 
can you contact me to my email if that is okay
Shruthi MN 28Shruthi MN 28
raj can u help me with the enitire code of updating multicurency