cancel
Showing results for 
Search instead for 
Did you mean: 
georgi_lubomiro
Nintex Newbie

Re: Is there a way to deploy a Nintex Form from a script (like powershell or feature) instead of a Export/Import?

Jump to solution

This won't work because the [Nintex.Forms.SharePoint.Services.NfWcfService] is not set to an actual service instance.

The below code uses a DLL from NintexFormsPublishExample sample found here:

http://help.nintex.com/en-US/sdks/SDK2013/#FormSDK/Topics/SDK_NF_API_OPS_NintexFormsPublishExample.h... 

 

I uploaded it here. Change the Path of the Custom DLL in the script to point to this DLL:

NintexFormsClient.dll - Google Drive 

This is the working code:

####Load SharePoint Management Shell
Add-PSSnapin "Microsoft.SharePoint.Powershell" -ErrorAction SilentlyContinue

####Load Nintex Forms DLLs
[void][System.Reflection.Assembly]::LoadWithPartialName("Nintex.Forms")
[void][System.Reflection.Assembly]::LoadWithPartialName("Nintex.Forms.SharePoint")

####Load Custom DLL.
Add-Type -Path "C:\Form_Poc\NintexFormsClient.dll"

####Input Info
$filePath = "C:\Form_Poc\Form.xml"
$webName = "http://sharepoint"
$ListName = "List"
$userName = "DOMAIN\User"
$passWord = "Pass"

####Create Credential
$cre = New-Object System.Management.Automation.PsCredential($userName, (ConvertTo-SecureString $passWord -AsPlainText -Force))

####Get File
[byte[]]$bytes = Get-Content $filePath -Encoding byte

####Get Web and List
$web = get-spweb $webName
$list = $web.Lists[$ListName]

####Get Content Type. Change the Content Type if necessary.
$ct = $list.ContentTypes[0]

####Get List ID, Content Type ID
$ctID = $ct.Id.ToString()
$listID = $list.ID.ToString()

####Prepare Form
$formMarkup = [Nintex.Forms.NfUtilities]::ConvertByteArrayToString($bytes);

####Set SharePoint Version (SharePoint2010 or SharePoint2013)
[NintexFormsClient.Version]$version = "SharePoint2013"

####Setup Context
$context = new-object NintexFormsClient.NfClientContext($webName,$cre,$version)

####Publish
$context.PublishForm($listID,$ctID,$formMarkup)

####Or Delete Form
#$context.DeleteForm($listID,$ctID)

0 Kudos
Reply
pravindahale
Nintex Newbie

Re: Is there a way to deploy a Nintex Form from a script (like powershell or feature) instead of a E

Jump to solution

Can we deploy Nintex form for content type using PowerShell? So form will be available for all lists where content type is attached.

0 Kudos
Reply