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 Triad’s customer. 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.

counting-sheep

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.  impleemnt 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 additinal 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.

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
}

Once you run the above script you will be able to get the number of tasks withing seconds.

Advertisements