3

We have enabled multiple currency in our org, and allow the user to set the currency on the Opportunity record. The user is able to change the value of the Currency field on the Opportunity object if there is NO Opportunity Line Item against it. But when you add a new Opportunity Line Item to an Opportunity record, the user is no longer able to change the Opportunity currency.

Why does the Opportunity currency become uneditable after a line item is added? Has anyone beeen able to make the currency editable on an Opp with a line item?

Thanks!

  • Are you using "Advanced Currency Management" or the standard multi-currency? The most obvious difference is the advanced allows historic FX rates. – Joel Mansford Sep 10 '12 at 14:57
  • Just the standard multi-currency. – Anup Sep 10 '12 at 14:57
  • This is related, I think, to being able to edit the Opportunity Amount directly until OpportunityLineItems are added. I don't believe there is any way to go back, once you've added a product. – Jeremy Nottingham Sep 10 '12 at 15:48
  • 1
    we have written custom (apex, visualforce) to take care of this same case. – Prafulla Patil Sep 10 '12 at 17:58
7

Why does the Opportunity currency become uneditable after a line item is added? Has anyone beeen able to make the currency editable on an Opp with a line item?

This is because the Opportunity Line Item (OLI) has a lookup to the PricebookEntry object. The PricebookEntry represents a product entry (an association between a Pricebook2 and Product2) in a price book.

The PricebookEntry must have a currency value (when multiple currency is enabled). I (believe) that it is this, that is actually preventing you from changing the currency on the Opportunity as all OLI lookups to PricebookEntry must have matching Currencies. (i.e An OLI must lookup a Product, using PriceBook, all in the Same Currency as the original Opportunity.)

Currently when you try to change the Opportunity Currency, at that point in time it will no longer match the Currency of the PricebookEntry and so would fail to match the criteria.

Has anyone beeen able to make the currency editable on an Opp with a line item?

I personally haven't done it myself but in principal it is possible via Apex and a button or link. The code would need to do the following:

  • Record ALL existing information about the OLI including lookups to related objects
  • Find the corresponding PricebookEntry lookups for the same Product2 and Pricebook2 with the new currency
  • Report an error if a match is not found (or skip that OLI)
  • Delete existing OLI records
  • Update the Currency of the Opportunity
  • Create New OLI records with the new currency and new PricebookEntry lookup values

This all sounds a bit of overkill for what should be a simple requirement but am not aware of another solution. So careful consideration will be required before undertaking the work.

Jason

  • Does this actually work? I tried something like this a couple of years ago, and found that the Opportunity seemed to be locked even after the OLIs have been deleted. Please post your results. – Jeremy Nottingham Sep 24 '12 at 16:39
  • I haven't written the code but have tested it by manually replicating the steps and yes you can change an Opportunity currency after deleting the OLIs so I can't see why it wouldn't work via Apex. – Jason Lawrence Sep 24 '12 at 20:02
0

This does not work if the currency is updated in a trigger. When you try to delete all the oli, you will get an error bc the opportunity is going to be updated and it is not yet free to change the currency. You can test it just by creating an opportunity with one oli, and then try to delete this oli. enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.