Nintex workflow has a number of different ways you can license their products. For on-premises installations Nintex have had a server based license for a long time. Since Nintex Workflow has appeared in office 365 they have had a different licensing model which makes the number of workflows and action relevant. they offer this model both in Office 365 and for on-premises solutions.
I’m not going to go into the details here, but imagine that you need to know how many actions you have left on your license? In my case I’m working with the on-premises version of SharePoint of one of my clients. I’m running SharePoint 2013.
So this morning I started manually counting the steps. Half way through I fell asleep so this didn’t work very well.
The better solution is to use PowerShell to count the number of actions in the workflow.
First of I exported my workflow giving me a .nwl file.
Then I read the content of the file using the following lines of PowerShell.
[xml]$xmlWorkflow = Get-Content C:\temp\Submit_documents.nwf
[xml]$xml = $xmlWorkflow.ExportedWorkflowWithListMetdata.ExportedWorkflowSeralized
$xmlWorkflowRootActionsConfig = $xml.ExportedWorkflow.Configurations.ActionConfigs
I now have some Xml contianing the action object. then I look throguh the xml and display the total number found.
$count = 0;
foreach ($actionConfig in $xmlWorkflowRootActionsConfig)
{
$subcount = doCount($actionConfig.NWActionConfig)
$count = $count + $subcount}
Write-Host $count
Just one more thing to do. implement a doCount function that takes the Xml for a number of Actions (NWActionConfig) from my xml
In short when you add an action to a Nintex workflow additional action are being created. These actions include:
- Nintex.Workflow.Activities.Adapters.NWState2Adapter
- Nintex.Workflow.Activities.Adapters.WFSequenceAdapter
- Nintex.Workflow.Activities.Adapters.WFIfElseBranchAdapter
- Nintex.Workflow.Activities.Adapters.NWSwitchBranchAdapter
There might quite well be more than the above list, but I only found the above.
[code lang=text]
function doCount($xml)
{
$count = 0
foreach ($xmlPart in $xml)
{
if ($xmlPart.ChildActivities -ne $null)
{
$subcount = doCount($xmlPart.ChildActivities.NWActionConfig)
$count = $count + $subcount
}
if ($xmlPart.TLabel -ne $null -and $xmlPart.TLabel -ne “” )
{
if ($xmlPart.Type -eq “Nintex.Workflow.Activities.Adapters.NWState2Adapter” )
{
#Ignore this
}
else
{
$count++
}
}
else
{
if($xmlPart.Type -eq “Nintex.Workflow.Activities.Adapters.WFSequenceAdapter” -or $xmlPart.Type -eq “Nintex.Workflow.Activities.Adapters.WFIfElseBranchAdapter” -or $xmlPart.Type -eq “Nintex.Workflow.Activities.Adapters.NWSwitchBranchAdapter”)
{
#Ignoring
}
else
{
#Ignoring
Write-Host -ForeGroundColor Red “Please consider adding ” $xmlPart.Type ” To the above list”
}
}
}
return $count
}
[/code]
Once you run the above script you will be able to get the number of tasks within seconds.
Hi,
Interesting blog post.
Have you tried to analyze your workflow with this tool: https://workflowanalyzer.codeplex.com/
What does the Action Count say and does it match with your result?
Hi Raphael,
I wasn’t aware of that tool. Interesting the tool gave me 123 actions where I got 119 actions. It looks like the tool doesn’t ignore some of the invisible actions.
Ok, so we then better use the Workflow Analyzer to get an Impression of how many Actions are in use. I think it’s not trivial to get to know exactly how many Actions are left with my subscription.
I had a further look into the ‘missing’ actions. My script is excluding the Nintex.Workflow.Activities.Adapters.WFSequenceAdapter actions which Nintex adds in when multiple actions appear in a condition action to bundle the actions in each of the two branches.