[SalesForce] Update ConversionRates for CurrencyType from Apex

I'm working on a small application in which I want the user to be able to enter a conversion rate on a VF page. The conversion rate should be saved in the CurrencyType object. I wanted to use something like this:

CurrencyType ct = new CurrencyType(ISOCode = 'GBP');
ct.ConversionRate = 4.0; //or some variable
upsert ct ISOCode;

But if I try to save this code I get the following error: DML not allowed on CurrencyType. How can I update the conversion rates from Apex?

Edit; If I change the upsert to update I still get the same error message; DML is not allowed on CurrencyType. Is there any other way to do an update in Apex, besided DML?

Best Answer

see below the supported calls for this object.

Supported Calls create(), describeSObjects(), getUpdated(), query(), retrieve(), search(), update()

*Note that upsert() is not supported. You need to query the object and then perform update().

Related Topic