Find your content:

Search form

You are here

Change Opportunity Currency after adding a Opp Line Item

 
Share

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!


Attribution to: Anup

Possible Suggestion/Solution #1

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


Attribution to: Yehiel Zafrany

Possible Suggestion/Solution #2

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


Attribution to: Jason Lawrence
This content is remixed from stackoverflow or stackexchange. Please visit https://salesforce.stackexchange.com/questions/1312

My Block Status

My Block Content