4

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?

2

2 Answers 2

1

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

2
  • 1
    Thanks for your answer, but again, this is for the API, I want to do this directly from Apex. Commented Jun 26, 2013 at 13:16
  • Hi, the answer is the same, this object does not support upserts unfortunately...
    – dacology
    Commented Jun 26, 2013 at 13:29
0

This cant be done from apex. Previously using the API was the only option.

See this post for details on how to do so

And here is an idea to allow for this in apex

It is possible to update this using flow, and you can call flow from apex.

I've been told that this should only be done in isolation and not part of other updates (which is why it was blocked in apex).

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .