You need to sign in to do that
Don't have an account?
Marcel dos Santos
Shared resources and flow bulkification
I have a Custom Object with a numeric field to be used as a counter. The reason for that is not important now.
I'm trying to create a Flow to update the counter for each new object I create.
I have now a Process and a Flow to achieve that. Whenever an object is inserted, the flow gather it's id and passes it as a paramter to the flow.
The flow has 3 components executing the following actions:
As an example, if the current max counter for the object is 4 and I insert 10 new objects, all the new objects will have the same counter 5, instead of 5 through 14.
Is there any way I can have a static variable there shared accross all flow instances in that transaction?
I'm trying to create a Flow to update the counter for each new object I create.
I have now a Process and a Flow to achieve that. Whenever an object is inserted, the flow gather it's id and passes it as a paramter to the flow.
The flow has 3 components executing the following actions:
- Lookup for the object just inserted, using the id informed by the process;
- Lookup for any object of that type sorting on the counter field desc. That will get the max value;
- Increments the value and update the newly inserted recorde with that counter.
As an example, if the current max counter for the object is 4 and I insert 10 new objects, all the new objects will have the same counter 5, instead of 5 through 14.
Is there any way I can have a static variable there shared accross all flow instances in that transaction?
Faced a similar issue in one of my project and the solution was pretty tricky. You would need to maintain a flag against the records of the object and manipulate the same via flow whenever you are updating the record with incremental number and while you are running an update via flow you need to add another check there to confirm if that flag has been changed for the current record or not and run the counter search loop again.
Hope this helps. Please mark as best answer if it does.
In case you need more details you can connect with me at gaurav.handoo@gmail.com
Cheers!!
Gaurav
The additional flag being mentioned is a checkbox field that was created on the object for maintaining a check in bulk scenario. Whenever you create temp record in SObj, add another criteria check for this checkbox to be false and mark the checkbox as true once the incremented value is calculated; this ways, whenever you are trying to refer the record again, it will not reuse the previous number.
Hope this helps.
Cheers!!
Gaurav