How to Publish Nintex Forms through PowerShell



Publishing Nintex form through PowerShell, was a challenge for me during last few weeks. After consulting Nintex team they have provided many valuable information related to the same topic.

I will go through each and every information which I have gathered. Finally I was able to publish the Nintex Form through PowerShell

Initially Nintex team has provided details to the in built web service for publishing a workflow.


Above link explains all available methods within the service 

·         Endpoint URL
·         DeleteForm
·         GetFormXml
·         PublishFormXml
The moment I tried to access the web service via browser, I got an error saying "End Point Not Found".

But later I found a valuable post on Nintex community by mattbriggs who has overcome same issue through Visual Studio Solution in his blog post Named asPublish a Form Using the Nintex Forms On Prem 2013 Web Service“.


Unfortunately in my corporate environment as a policy we are not publishing any custom build WSP solutions in to our farm.
In the Same page sonisick has provided an amazing solution to implement the same in PowerShell.
I was able to use same functions as it was and implemented a new function to get XML Form downloaded to a custom folder.
All credits should go to sonisick and mattbriggs I’m publishing their methods along with the additional form download functionality which I was implemented using their references.
PowerShell Code Function Definitions
If I say reused method, that means it was copied from reply of sonisick from the above specified blog post
Function Name
Purpose
Create-Folder
If not exists, Create a new folder to hold downloaded XML file
DecodeXMLString
Decode serialized JSON output in to XML string
Nintex-PublishFormToNewList
Publish the XML form in to destination SharePoint List (reused same method from Sonisick’s reply )
Get-FormDigest
Reused method
Nintex-GetJsonFormFromXml
Reused Method
Read-FileBytes
Reused Method
Get-SPListBylistName
This is modified method from above Post to get SPList object from List name (instead of internal name of the list)
checkFileExists
Used to check XML file already generated or not for same list
Get-NintexFormXML
Implemented to download the XML File from the List using GetFormXML web service method.
Publish-NintexForm
Reused Method – Get-NintexFormXML method included to get XML File instead of hardcoded path

Again Please Note Below Solution I have created as part of Creating Sub Sites and Publishing their Nintex Forms via PowerShell. Some of the parameters might not required for you to use within this Script

Creating Sub Sites and Setting Master Page through PowerShell, I have discussed on my previous Post

To Publish the Nintex Form you can use the function as follows Download Entire Script from here

Publish-NintexForm -templateSiteURL $sourceSiteURL -destinationSiteURL $subSiteUrl -listNameToPublishForm $listNameToPoblushForm -FolderPath $xmlFileFolderPath -initiatorCredentials $Credentials

Download Entire Script from here


Again Special Thanks should go to sonisick and mattbriggs  
Hope this might help someone.
Cheers 

Tharindu

Popular posts from this blog

How to Create Host Header to SharePoint Web Application

System.Data.SqlClient.SqlException (0x80131904): The EXECUTE permission - User Profile Issue

How to add PDF Icon in SharePoint