I have a Visualforce page which create a product record, a priceBookEntry record and a opportunityLineItem record.
In my code, I first create the product then the priceBookEntry and the opportunityLineItem.
If I try to create the OpportunityLineItem record between the opportunity and the pricebook as an other user, it works well, it just doesn't work with one user.
The currency of the opportunity is USD and the currency of the priceBookEntry is AED.
This is my code :
this.theProductToInsert.IsActive = true; insert this.theProductToInsert; PriceBookEntry thePriceBookEntry = new PriceBookEntry( IsActive = true, Pricebook2Id = this.thePriceBook.Id, Product2Id = this.theProductToInsert.Id, UnitPrice = 1 ); insert thePriceBookEntry; System.debug('*** thePriceBookEntry: ' + thePriceBookEntry); insert new OpportunityLineItem( OpportunityId = this.theOpportunity.Id, PricebookEntryId = thePriceBookEntry.Id, Quantity = this.theOpportunityLineItem.Quantity, UnitPrice = this.theOpportunityLineItem.UnitPrice, Status__c = this.theOpportunityLineItem.Status__c, Lead_time__c = this.theOpportunityLineItem.Lead_time__c );
How the currency of the priceBookEntry is selected please?