Quantcast
Viewing all articles
Browse latest Browse all 1058

Deploy/Publish Nintex Workflow to Multiple Lists with PowerShell and Nintex Web Service

Requirement: We have three Nintex workflows. These three workflows to be deployed to all document libraries of a sub-site.

Nintex workflows provides web services to deploy Nintex workflow to multiple lists and libraries, which is explained in one of the Nintex whitepaper: How to create a workflow that automatically deploys other workflows, which calls the web service to publish provided workflow to multiple site's lists.

Instead of creating another workflow to deploy a workflow, I decided to use PowerShell and Nintex Web Service to deploy workflows on multiple lists.
You can use the same method, if you want to update your existing workflow with new workflow content!
Here goes my PowerShell script:

[void][System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint")

#Region MOSS2007-CmdLets

Function global:Get-SPSite()
{
  Param( [Parameter(Mandatory=$true)] [string]$SiteCollURL )
 
   if($SiteCollURL -ne '')
    {
    return new-Object Microsoft.SharePoint.SPSite($SiteCollURL)
   }
}

Function global:Get-SPWeb()
{
 Param( [Parameter(Mandatory=$true)] [string]$SiteURL )
  $site = Get-SPSite($SiteURL)
        if($site -ne $null)
            {
               $web=$site.OpenWeb();
            }
    return $web
}
#EndRegion

#Target SharePoint site URL
$WebURL="http://sharepoint.crescent.com/finance/CustomerApproval/"
#Get the Target Site
$Web=Get-SPWeb $WebURL
#Get the Target Lists 

#Nintex Web Service URL
$WebSrvUrl=$WebURL+"_vti_bin/nintexworkflow/workflow.asmx"

$proxy=New-WebServiceProxy -Uri $WebSrvUrl -UseDefaultCredential
$proxy.URL=$WebSrvUrl
#Path of the NWF Workflow File
$WorkflowFile= "C:\Documents and Settings\Salaudeen\Desktop\CustApproval.nwf"

#Get the Workflow from file
$NWFcontent = get-content $WorkflowFile

foreach($List in $web.lists)
 {
  #Get only document libraries. Leave the hidden and "Pending Approval Task" Document Library
  if ( ($List.BaseType -eq "DocumentLibrary") -and ($List.Hidden -eq $false) -and ($List.Title -ne "Pending Approval Tasks") )
   {
     write-host "Workflow is being Published to: "$List
     $proxy.PublishFromNWFXml($NWFcontent, $List.Title ,$List.Title+" Approval", $true)
     write-host "Done!"
   }
 }
If your workflow fails for some reason (e.g. column not found in the target list), workflow will be placed under "Unpublished workflows" category
Image may be NSFW.
Clik here to view.

Viewing all articles
Browse latest Browse all 1058

Trending Articles