+ Start a Discussion
Jeff GJeff G 

Product Creation Flow Won't Work in Conjunction with After Insert Trigger


I am trying to add opportunity products to its associated Opportunity by using a flow, and then based on the custom field values of the products, I want to update fields on the Opportunity via a trigger. The trigger does this by referencing the ID and OpportunityID of the product being inserted or updated.

However, when I have both the trigger and flow activated, the flow always fails and returns the following error:
caused by element : FlowRecordCreate.CreateXTPProduct
caused by: UPSERT --- UPSERT FAILED ---  ERRORS :  (CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY) TestUpdateOppCheckboxes: execution of AfterInsert ---  for SFDC record with ID : null, 

I assume this means that when a product is created in the flow, it is not assigned an ID (at least not immediately), and this prevents the trigger from successfully executing since it needs an ID to refer to the product. But I'm under the impression that product ID's are automatically generated for the product after the flow is executed.

Does anyone have any suggestions? Thanks!


ShashankShashank (Salesforce Developers) 
Referencing the ID is not working for you here. Would you be abble to post your trigger code so that I can suggest anything?