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
sddodsonsddodson 

Adding a line item to an opportunity in a flow

I am trying to have my flow add a line item to an opportunity based on input from a dynamic choice drop down with all the products.

 

 

I am using record create and OpportunityLineItem:

 

 opportunityid equals a variable that contains the appropriate opportunity id number

PricebookEntryId equals dynamic choice of the products

Quantity equals 1

 

When I try to run the flow, i get the following error message:

 

Encountered unhandled fault when running process Beginning_of_Renewal_Process/301c00000004EfV exception by user/organization: 00Dc00000001coI/{4} Source organization: 00D80000000dqvZ (null)

interaction.sfdc.adapter.rules.SalesforceRuleBrokenException: UPSERT --- UPSERT FAILED ---  ERRORS :  (FIELD_INTEGRITY_EXCEPTION) field integrity exception: TotalPrice (total price must be specified) ---  for SFDC record with ID : null,

 

caused by element : Data update.Add_line_item_to_newly_created_opportunity

 

caused by: interaction.sfdc.adapter.rules.SalesforceRuleBrokenException: UPSERT --- UPSERT FAILED ---  ERRORS :  (FIELD_INTEGRITY_EXCEPTION) field integrity exception: TotalPrice (total price must be specified) ---  for SFDC record with ID : null, 

 

 

Is there an easy fix for this or am I going about this completely the wrong way?

 

Thanks for any advice!

 

Best Answer chosen by Admin (Salesforce Developers) 
Jeff MayJeff May

For OpportunityLineItems (Opportunity Products in the UI), you need to set either the TotalPrice or the UnitPrice.  Here is a link the the Apex object description of Opp Line Items.   http://www.salesforce.com/us/developer/docs/api/Content/sforce_api_objects_opportunitylineitem.htm

All Answers

Blake TanonBlake Tanon

Is the TotalPrice field required?

sddodsonsddodson
I don't believe so, I don't even see that as a field on opportunities or products. Is there some place else I should look?
Jeff MayJeff May

For OpportunityLineItems (Opportunity Products in the UI), you need to set either the TotalPrice or the UnitPrice.  Here is a link the the Apex object description of Opp Line Items.   http://www.salesforce.com/us/developer/docs/api/Content/sforce_api_objects_opportunitylineitem.htm

This was selected as the best answer
sddodsonsddodson

This helped and I was able to get it!  Thank you!

ColeCColeC
I created a flow creating an Opportunity Line Item setting "TotalPrice". It tested perfectly for systems admin but failed for other profiles. I had to switch to "UnitPrice" and it works. I read on other threads that TotalPrice is buggy - it might be the product of quantity and UnitPrice . . . whether or not that is true, I would hesitate to use it again. I would default to UnitPrice.