Search code examples
salesforcesalesforce-lightning

Error in Salesforce flow: INSUFFICIENT_ACCESS_ON_CROSS_REFERENCE_ENTITY


Error detected during debug:

Create one OpportunityLineItem record where

OpportunityId = {!$Record.ConvertedOpportunityId} (null)
Product2Id = {!get_related_Product.Id} (01t5j000000I80nAAC)
Quantity = {!DefaulQuantityOfProduct} (1)
TotalPrice = {!TotalPriceDefaultForNewOpp} ($637.54)

Result

Info
Failed to create record.
Info
Error Occurred:

This error occurred when the flow tried to create records: INSUFFICIENT_ACCESS_ON_CROSS_REFERENCE_ENTITY: insufficient access rights on cross-reference id. You can look up ExceptionCode values in the SOAP API Developer Guide.

Manually or using Apex, I can add a record. The fields that I add (opportunityid,Quantity,TotalPrice,Product2id) are not read-only. I need a detailed answer. Am I missing some permission?

1 flow schema

2 trigger condition

3 get related record

4 create new record


Solution

  • OpportunityId = {!$Record.ConvertedOpportunityId} (null)

    This looks like the opportunity doesn't exist yet (got any errors? Do you create them always or only when certain condition is met? Did it fail?). Or it exists but it just has been inserted, SF didn't manage to update the Lead with the Id yet? Maybe add entry criteria that check if the field is populated.

    Lead conversion is bit nasty topic, see https://salesforce.stackexchange.com/questions/3956/lead-conversion-trigger-order-of-execution

    Actually you might be better of on SF stackexchange, more admins over there and flows are no-code solution so not a good fit for stackoverflow?