How to Update Nintex Workflow with No New Instances in SharePoint 2013 Using CSOM PowerShell Script

Sathish Nadarajan
 
Solution Architect
December 17, 2019
 
Rate this article
 
Views
933

After a long time, faced with a different scenario. The site collection has various lists and there are a lot of Nintex workflows associated to those lists. I was about to populate data for those lists using a backend mechanism, but don’t want those workflows to be triggered. Provided the Scenario, I don’t want to delete and attach the workflows again. Rather, there is an option called “No New instances” in the workflow properties. But, since we had many lists, can’t do this manually. Hence, came up with a script. Thought of sharing with the community.
When we do manually, we will go to the workflow settings of the list and click on the “Remove, Block or Restore a workflow”

Once, we click that, the next screen would be as below where we can toggle between the properties.

The below script will toggle this property.

Clear-Host

# Connects and Creates Context
Connect-PnPOnline https://SiteCollectionURL -CurrentCredentials

[System.Collections.ArrayList]$listsToUpdateWorkflowStatus = Get-PnPList | Where-Object {$_.Title.StartsWith('Our Lists Prefix') }

$ctx=Get-PnPContext

foreach ($list in $listsToUpdateWorkflowStatus)
{
     
        $ctx.load($list.WorkflowAssociations)
        $ctx.ExecuteQuery()
        $list.WorkflowAssociations
        $workflowAssociation = $list.WorkflowAssociations[0]
        # $workflowAssociation.DeleteObject()
        $workflowAssociation.Enabled = $false
        $workflowAssociation.Update()
        $list.Update()
        
        $ctx.ExecuteQuery()
     
}

Happy Coding,
Sathish Nadarajan.

Category : CSOM, PowerShell, SharePoint

Author Info

Sathish Nadarajan
 
Solution Architect
 
Rate this article
 
Sathish is a Microsoft MVP for SharePoint (Office Servers and Services) having 15+ years of experience in Microsoft Technologies. He holds a Masters Degree in Computer Aided Design and Business ...read more
 

Leave a comment