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
Jaime StuardoJaime Stuardo 

Problem adding a product with different currency

Hello, when setting USD as the currency for a line item of an opportunity, after setting the PriceBookEntry currency to USD, I get this error:

"Unable to create/update fields: CurrencyIsoCode. Please check the security settings of this field and verify that it is read/write for your profile or permission set."

What do I need to check?

The product has the active price in USD.

One thing took my attention is that when I am using Salesforce webpage, I get that the Price Book entry has the ID 01u400000044tqC, however, when I use the following query:
 
Select Id From PricebookEntry WHERE CurrencyIsoCode = '%s' AND PriceBook2.Id = '%s' AND Product2.SKU__c = '%s' AND IsActive = true AND Product2.IsActive = true
I get this Price Book entry Id 01u400000044tqCAAQ.

Is it normal to have AAQ added to the real ID?

Thanks
Jaime
Best Answer chosen by Jaime Stuardo
JayantJayant
Also, OpportunityLineItem would automatically inherit the currency from the PriceBookEntry, you do not need to explicitly set it. And a single Opportunity can't have line items with multiple currencies, only line items with same currency as the Opportunity can be added to an Opportunity.

All Answers

JayantJayant
Its okay, the 15-character id is case sensitive and the one displayed in classic UI. 18-character Id is the equivalent case insensitive one and is what exists in database. Certain legacy systems are case insensitive by nature and thus a 15-character 01u400000044tq and a 01u400000044tQ would be interpreted as same by them, so the 18-character one is needed :).

Is your Org multi-currency enabled ? Only Orgs with multi-currency enabled allow interactions with the CurrencyIsoCode field IMHO, though I might be wrong.
JayantJayant
Also, OpportunityLineItem would automatically inherit the currency from the PriceBookEntry, you do not need to explicitly set it. And a single Opportunity can't have line items with multiple currencies, only line items with same currency as the Opportunity can be added to an Opportunity.
This was selected as the best answer
Jaime StuardoJaime Stuardo
Thank you!! your clue was the solution. I stopped sending the currency in the line item. Only the opportunity object was sent with the currency and it worked!