I have a Platform-Event Triggered Flow which does the following:
- After insert of a Platform Event record...
- Get OpportunityLineItem records related to an Opportunity
- If the result of the above query was not null (i.e. at least 1 record exists), delete all the records from the Collection above, and then create new line items.
- If the result of the above query IS null, then don't try to delete any line items, just create new ones.
The problem: When testing this flow on an Opportunity record which has 1 line item, I'm getting the following error:
Error Occurred: The flow tried to delete these records: 00k2z000002co9wAAA. This error occurred: ENTITY_IS_DELETED: entity is deleted
There are 2 strange parts to this error:
- If the record doesn't exist (it doesn't - I checked the database), why was it queried in the Get Element and attempted to be deleted??
- The existing line item record that SHOULD be deleted by the flow has a completely different record ID. Where on earth is the record ID in the error even coming from?? -> 00k2z000002co9wAAA ... It's like some ghost record hanging around.
Notes:
- There are some existing triggers on Opportunity, but none that will fire for this event as far as I can tell
- There are no triggers or other automation on OpportunityLineItem