One of the skills every Nintex workflow designer has to learn is how to debug a workflow. As Andrew Glasser has pointed out in his post Tips on Debugging Workflows, the most common way to do this is to Log information to the History List. In addition to this there are also times that I will use the Send Notification action to email myself some information at a certain point in the workflow. In both cases however, these are typically only actions you want to take when developing/debugging a workflow, and don't need them once it's up and running in production. So what's the best way to turn off these actions once you're ready to publish your workflow?
The Problem
The most straight forward way is to go through your workflow before you publish it and either disable or delete these actions. However depending on how many actions you have, this could be very time consuming. Plus, if you ever needed to debug something in the future, you'd need to edit the workflow and turn them all back on again. If you opted to delete them, that would give you even more work to do.
The Solution
The solution I have found for this problem is to use a list to store an indicator for whether logging is on or off for a particular workflow. I setup my workflows to do a lookup to that list and determine whether there should be any logging. All of my logging actions are contained within a Run If action that will only run if the logging indicator is turned on. This way I can turn logging on or off for any workflow simply by changing the logging value in the list. (This is the same concept Andrew Glasser has written about in Using Workflow Configuration Lists in O365, but just a different application. I like Andrew's nomenclature of calling it a "Configuration List", so I'm going to stick with that.)
The Configuration List
The first step is to create your configuration list to store the logging indicator. I use the Title field to store the workflow name. I then create a Choice field to store the logging indicator. I made my choices "On" and "Off", and set the field as Radio Buttons. I also make sure to set a default value so I don't run into an issue with the workflow where I find no logging value when I attempt to look it up.
Once the list is setup, I can then add entries for my workflows and set the logging value. Make sure that the workflow name you enter matches your workflow names exactly. If you ever change your workflow name, you'll need to update it here as well.
Once the list is setup, I can then add entries for my workflows and set the logging value. Make sure that the workflow name you enter matches your workflow names exactly. If you ever change your workflow name, you'll need to update it here as well.
The UDA
Since I'm planning to reuse this solution for all of my workflows, I'm going to create a UDA called "Check Logging Status" to do the lookup of the logging indicator. I setup my UDA with two parameters. The input parameter is the Workflow Name, and the output parameter is the Logging Status. Both are text parameters.
The only action in the UDA is a Query List action. This will lookup the entry with the matching workflow name on the configuration list we created above, and then return the logging status indicator for that entry.
The Workflow Setup
Once the UDA is created, you can now use it in a workflow. Whenever I create a new workflow, the first thing I do is insert the Check Logging Status UDA.
UDA Setup
After you add the UDA, you'll need to setup the Input and Output parameters. For the Input parameters, you will pass the Workflow Title. Since this is part of the Workflow Context data, you can just select it from that list. For the Output parameter, I create a single line of text variable to save the returned logging status.
Tip: If you want to save yourself some time in future workflows, you can save this configured UDA as a snippet. Just add an Action set action and put the UDA within it. Then save that as a snippet. This way you can add that snippet to future workflows, and it will already be setup and create your logging variable for you as well.
Run If Setup
The key to this solution is putting your logging actions within a Run If action that only runs if the logging is turned on. The first time you setup a workflow you'll need to create your Run If action using the UDA output. Setup the Run If to only run if the Logging variable is equal to "On".
Now within the Run If action you can add any type of workflow logging that you want to do.
Create Logging Snippet
You don't want to have to setup a Run If each time you want to log something. So the first time you setup the Run If, you'll want to save it as a snippet that can be reused. To do this, add an Action Set action, and put the Run If within it. Within the Run If, I also add an empty Log in history list action. This way it's already there when I add the snippet. Click on the Action set menu and save as a snippet. Name it something that will be easy to remember in the future. I called mine "Log if Logging On".
When you need to add a logging action to a workflow in the future, just go to your snippets and insert your saved Logging snippet, and then setup what you want to log.
Conclusion
With this setup in place, you now have a Debug Mode for your workflows that you can turn on or off from a list. When you create a new workflow, all you have to do is insert two saved snippets and you're ready to go. Once you have a workflow built and ready for production, all you have to do is go to the configuration list and set the logging status to "Off". If an issue comes up in the future and you needed to debug it, you can just as easily turn it back on. No more having edit the workflow and manually turn off or on each workflow logging action. Try it out and let me know how it works for you.
References
Using Workflow Configuration Lists in O365