We have 2 objects - ObjectA and ObjectB. Object B has a lookup to ObjectA (so ObjectA is parent and ObjectB is child). We need to calculate no. of Active ObjectB records and show it in ObjectA record page. If it was M-D relationship, roll-up summary field was the solution, unfortunately it is not and it cannot be. We cannot have a report chart shown since this field is used for various other calculations.
So, we used Process Builder + Flow to calculate the no. of Active ObjectB records. On create/update of ObjectB, we pass the ObjectA__c reference to the flow, get all the ObjectB filtered on Status = Active and store it in a list variable. This happens in the loop element of flow and outside the loop element (after last), we update ObjectA's ActiveCount__c field.
References - https://success.salesforce.com/answers?id=90630000000476cAAA https://admin.salesforce.com/use-flow-builder-to-create-a-roll-up-summary-field Create a roll-up summary field on Lookup without coding
This was all good when we tested by creating ObjectB records. But now when do proper testing, where we had 20 ObjectB records inserted, we got DUPLICATE_VALUE: Maximum number of duplicate updates in one batch (12 allowed). Attempt to update Id more than once in this Api call: ObjectAId
I am wondering if this is known issue. But as per documentations, Salesforce suggests that Flows are bulkified. Is this truly bulkified or am I doing something wrong?