We have a flow which gets triggered when an Order record is activated. Flow does some query etc and creates a record of a related Object BillingSchedule (BillingSchedule has a lookup to Order).
As part of testing, our team cam eup with an impractical scenario, but we have to fix it nevertheless.
If we create 2 copies of the flow (so exact same flow, just 2 different API names), they both gets triggered at the same time and create 2 records of BillingSchedule at the same time. We do not want that.
Putting any checks within the flow like - "If a BillingSchedule exists for this order, dont create one" doesn't stop the issue, because both flows run perfectly in sync, and when they reach this validation, either of the flow has created the record in database yet. These checks are there and prevent duplicate records of BillingSchedule from being created, when flow is run multiple times sequentially. But running two instances of same flow bypasses these validations.
Also, we do not have ability to put a constraint of "unique" on the lookup field (due to other business requirements).
Is there anything in salesforce platform that can help resolve this?
If i change the flow from being record driven to platform event driven, we run into same issue. Lets say when order is activated, a platform event is published. Now if we create multiple copies of our flow, they ALL will subscribe to this event, and they ALL will run at the same time.