I faced a strange issue w.r.t Flows which was creating Duplicate records when I did bulk update of records. Details are as follows.

We have a custom object Rate Card which stores information related to rates(Currency fields) based on the service and the account(master detail relationship between Account and Rate Card). Let’s say for physiotherapy service and the account (let’s say ‘HomeCare’), we capture several rate fields(Daily Rate, Half-a-day Rate, Hourly Rate etc). Also, we have Validated flag and once the record is validated(by checking the flag), we trigger a flow(below screenshot) from the process and it will create Pricebook, Product and Pricebook entry records since we want to create Opportunity and Opportunity Product from the Rate Card record.

flow screenshot

Each Pricebook corresponds to an account and Products which will be the services(e.g. Physiotherapy) that we provide to the account.

First step in the flow is to check if the pricebook exists and if it exists, create the product. If it doesn’t exist, create the pricebook and create the product.

Then, create a Pricebook Entry record for Standard Pricebook and a Pricebook Entry record for custom pricebook(associate the pricebook and product created in previous steps).

This works absolutely fine when I validate Rate Card records manually one by one in UI. But, we have around 500+Rate Card records for which we need to create Pricebook, Product and Pricebook Entry records. So, I went ahead and used dataloader.io to update Validated flag and unfortunately, flow created duplicate Pricebook records and this issue happens only for the account which has more than one Rate Card.

When I investigated further, I could find this link https://developer.salesforce.com/forums/ForumsMain?id=906F0000000ArtkIAC which highlights the same issue.

When I checked the logs, it looks like the flow runs in parallel for all the records that I updated so the first step Lookup Pricebook did not find the Pricebook for the  updated records, hence created duplicate entries.

Then, I found a workaround by extracting the accounts which has more than one Rate Card. From the list, make sure that I extracted Rate Card records which has unique account ids and update the Validated flag.  System created Pricebook, Products and Pricebook Entry as expected without any duplicates.Then, updated the Validated flag for the rest of the records and system created Pricebook, Products and Pricebook Entry records.

Has anyone else faced this issue before? Is it a known issue and if so, is there an idea for it in Salesforce Success community? Please let me know your comments.