maxmanzero

Using Power Shell to create Site Collection Level Workflow Constants

Blog Post created by maxmanzero on Dec 31, 2015

This article provides a sample Power Shell script to insert workflow constants into Nintex 2010 at the site collection level.

 

I am working on an enterprise platform for the U.S. Air Force that involves SharePoint and Nintex running in an on-premise enclave.

 

Recently we started working on our installation process for the solutions that support the integration layer of our system for 3rd party developers.

 

One of the issues our Q.A. department constantly complains about is having to create workflow constants manually after an installation is performed.

 

I worked with our release engineer to find a good spot in the scripted installer to add the workflow constants to the target SharePoint site collection, but I could not figure out how to insert them at the site collection level only at the site level.

 

Finally I discovered you can add constants directly to the site collection level by passing Guid.Empty as the WebId parameter when creating a workflow constant object in code. This is a great way to publish integration information for your workflows which you can be certain won't be changed by an adventurous user. =)

 

$web = Get-SPWeb -Identity "SiteUrlHere"

 

$guidEmpty = [System.Guid]::Empty;

 

$wfConstant = New-Object Nintex.Workflow.WorkflowConstant("Name", "Description", "Value", $false, $web.Site.Id, $guidEmpty, "String", $false);

 

$wfConstant.Update();

Outcomes