Recently one of our clients, with whom we are doing a Salesforce Case Management Project with, asked us to develop logic that would allow Cases to be created with certain criteria two weeks before an event starts. These particular events require multiple criteria to be completed before the registrant can attend that specific event.
- Payment for the registration must be complete (they allow monthly payments)
- Contact information forms must be complete.
- “Store Credit” must either be declined or added (these events are for kids who can purchase food in the store during the event).
- A “stay with friends” form must not be pending (kids can attend the event with their friends).
All four of these were to be separate cases that would be created if they were not satisfied within two weeks of the event starting. I.e. you obviously can’t attend if you haven’t finished paying for it.
If you’ve done a fair amount of work in Workflow Rules or Process Builder, you’re probably familiar with the idea of a Timed-Based Rule or a Scheduled Action. Both of these items are what Salesforce calls “flow interviews”. The maximum number of waiting flow interviews you can have at any one point in time is 30,000. If you’re just coming up on this problem then you’re probably already bashing your head for all the work you did meticulously creating your Processes in Process Builder and now you get to delete them (wahooo….).
Oh, and by the way if your case is anything like mine, you may not have realized that there is another limit that also causes problems. If the records in the object you’re trying to create Scheduled Actions for are created by an API that runs every night at midnight, then all of your scheduled actions are scheduled to run during that same hour whenever it executes. This is where the execution of more than 1,000 flow interviews per hour limitation comes into play. Because all of my 30,000+ Scheduled Actions are scheduled to run at midnight, two weeks before the event starts, it will only ever execute 1,000 of those Scheduled Actions.
You’re likely also trying to figure out how you can get around these two limitations given that you still have to deliver regardless of what Salesforce says. By the way, I did connect with Partner Support and they politely told me these are “hard” limitations (i.e. we’re not changing this for you).
Well, I’m sorry to say that for this specific case, there is no (declarative) solution in Salesforce. Even creating all four of these cases in one giant case still would create more than 30,000 waiting interviews. Obviously if you have have access to developers or can write Apex yourself, then you could potentially figure this out. At Venn Technology we’re laser focused on delivering declarative solutions as code can become outdate, stop working, break your own code, etc.
Without an simple solution in Salesforce we turned to our favorite middle-ware tool Workato. Workato allows your to declaratively connect different APIs to each other without writing a single line of code. It also allows you to work within a single platform to perform processes that can’t be done declaratively by the platform itself.
Using Nested Loops and Flags
In Workato we devised a simple solution to run through each Event and their related registrations. Instead of running through each Registration when it’s created or edited (in Salesforce) we individually pulled each Event then polled the Registrations tied to that event. By doing this we were able to limit the amount of registrations we looked at in our nested loop. Below is a step by step process on how to set this up in Workato.
The Nested Loops
- Create a new Workato Recipe and utilized the Scheduler connector. This will allow you to trigger this recipe whenever you need, i.e. nightly at midnight, once a week on Sunday, etc.
- Select Salesforce as your connector for the first action (and every proceeding action) so we can search for all of our Events.
- Our nested for loop to run through all of the Registrations for that specific Event.
- After creating our case, we want to prevent the next For Loop from grabbing this record again so we flag this record by looking grabbing the Record ID.
- You can get it from the For Loop action you’re step is under.
- The flag to prevent another case from being created.
Cloning your Loops
- Use the clone button to create multiple Nested For Loops. This will allow you to run through thousands of records.
This entire process could take up multiple posts to go through the entire process step by step. Hopefully this overview will point you in the right direction to get your project delivered on time. If you’re in a serious time crunch, we’re always here to help and have obviously felt the pain you’re currently feeling right now. Feel free to reach out to us and we help you solve this fast!