Visual Workflow allows us to automate business processes by building applications, known as Flows. Using Flows, users can: (1) collect information; or, (2) they can update, edit, or create records in Salesforce. Furthermore, Flows can execute logic, interact with the Salesforce database, call Apex classes, Platform Events, and guide users through various screens to streamline the process of collecting and updating data. Once a Flow is built, an Admin can make the Flow available to the right users or systems.
Just like most things in life, however, Visual Workflow is not immune to bugs :(; and, neither is it any easier to debug Visual Workflows :(. Salesforce, however, does offer handful of debugging tools – such as, a user can use Fault Email sent by Salesforce (not very helpful in every case); or, use Screen elements (adding a temporary element); or, last but not least, leverage standard Debug Log. Each option, however, has its pros and cons. If one lacks experience on how to read a Debug Log then, using screen elements is quite helpful in debugging a flow. Setting Debug Log is quite easy but understanding/reading each and every line of Debug Log message/outcome is relatively challenging. If you are interested in developing mastery on how to read Debug Logs (Only FLow part) in Salesforce then, please read this article.
You might have created a Flow with multiple screens, assignment or Record elements. After development, the second step is to test the Flow, to make sure that it is working as per the design (obviously based on business requirements).
Before Summer’18 release, we were using Screen elements to make sure that Flow is passing correct data to next element.
In the above example, I am using Screen element just to debug/test the Flow to make sure that it is passing correct data – i.e. Lead ID, in my case – to the next element Add to Campaign (Record Create) element.
After Summer’18 release, however, with just a few clicks, you can now debug your Flow with a built-in debug tool within the Cloud Flow Designer! No need to add Screen elements to test the outcome. Cloud Flow Designer now offers a debug option to help you test and troubleshoot your flows. Easily set input variables, quickly restart flows and view all the gory details of what’s happening in real time as your flow executes. The new feature includes the following capabilities:
- Easily specify the values of input variables. After running the flow, you can quickly change those values and rerun the flow.
- Choose whether sub-flow elements are running the latest version of each referenced flow.
- View step-by-step details of all operations, actions, and variable assignments as the flow execute them.
- At any time, even mid-run, quickly restart the flow so that you can try a different branch.
In this article, I am going to show you how one can use the new Flow debugging technique that allows you to debug in the Cloud Flow Designer. Let us start with a business use case.
Business Use Case
Marie Gallagher is working as System administrator at GurukulOnCloud. He received a requirement from upper management to create a Flow that allows reps to create Lead and then associate it with a Campaign.
The solution for the above business requirement
This article is fully focused on the new debugging technique that allows you to debug the Flow in the Cloud Flow Designer. So I am not going to explain the steps to create the Flow for the above business requirement. But, for your reference, however, I have created an unmanaged package which you can install in your Org. For a deeper dive, view the following video and create a sample Flow!
Notice that, in the video, I am not using any screen element after Record Create (create lead record) element to verify the lead record ID to make sure that data is being correctly processed by the Flow. Instead, I am going to show you how one can use newly built-in debug tool:
- To start the debug process, click on the Debug button (only available in Summer’18 Orgs).
- It will open another window where you can set the Debug Options and Input Variables. In our case, enter a valid Campaign ID in CampaignID field, as shown in the following screenshot:
- Once you are done, click on the Run button.
- On the next screen provide the input data – to the Flow – to create a lead record, as shown in the following screenshot:
- If you look at the preceding screenshot carefully, it has two additional options:
- Pause – Pause your test/debug and resume it later. But note that ‘later’ means that it will open a normal Flow run screen, not debug screen with populated data.
- Run Again – Restart your test/debug from scratch or run it again with the same inputs that you previously entered.
- Once you are done with entering the lead data click on the Next button. It will create a lead and a Lead ID will be generated by the Flow. No need to add additional Screen element just to verify the outcome.
- Well done guys. Now you understand how to debug your Flow! A savvy tester tests a positive as well as a negative scenario; since you are in this coveted club, now, let us test a negative scenario:
- Let’s take a negative scenario and see how this built-in debug tool helps when Flow fails at runtime.
- Go ahead guys and create a Validation Rule on the Lead object as shown in the following screenshot:
- Re-run the complete debug process once again. To do so follow the steps 1-6.
- This time Flow will fail to create a record, and you will get the same message on the screen with reason:
- Yes! Wowed by the power of the new Debug tool? Me too! Having gone through the above exercise, now you understand how helpful this Debug tool in the Cloud Flow Designer is! Most of us would agree that it is better, quicker and easier way to debug a Flow – rather than setting up standard Debug Log and reading a convoluted mammoth log file.
Whether you are testing a new flow or troubleshooting a flow that failed, the debug option in the Cloud Flow Designer is now your new best friend!
Things to remember
- Debugging or testing a flow actually runs the flow and performs actual actions – including any DML operations and Apex code execution. Remember, closing or restarting a running flow does not roll back its previously executed actions, callouts, and changes committed to the database.
- You can not pass values into input variables of type collection, sObject, and sObject Collection variable.
- Clicking Pause or executing a Wait element closes the flow and ends debugging.
I hope you gained valuable insights from the blog about how to debug a Flow in the Cloud Flow Designer.!! Yes, go ahead! Show off your newly acquired skills to your friends, colleagues, and families!
Please feel free to add constructive comments, insights – and yes, challenges too! – to the blog. Good Luck in your Journey towards becoming a Salesforce Ninja!
Technical Editor and Proofreader: - Munira Majmundar