vacoder
Process Pupil

Create a Nintex Workflow History List in Powershell

I script my site setups and am currently creating Workflow History Lists by calling $spweb.ListTemplates["Workflow History"] and adding it to the site via List.add()

This works but I then have to go into the Manage Workflow History Lists, highlight the list and click 'Enable'.

There is not Enable() method on the workflow history list that is accessible to me after I get a reference to the newly created history list.

This begs the question if I should be using a different template to create these lists and if not do yo know the method that is called to enable these lists?

Thanks!

0 Kudos
Reply
3 Replies
vacoder
Process Pupil

Re: Create a Nintex Workflow History List in Powershell

Another issue is that on the NintexWorkflowHistory list that is created on a site by Nintex there is an eventReciever which has a class Nintex.Workflow.Features.WorkflowHistoryEventReciever

The History Lists I create do not have this event receiver at the time of creation. When I revisit these lists the event receiver is added so perhaps there is another mechanism that insures these are added? Like when a workflow is associated with the History List or when earlier when it is enabled? At any rate It appears there is something else happening under the hood when we created these through the Nintex GUI.

Incidentally, I am able to attach the event Receiver to the lists like this:

$type = "ItemAdded"
$assembly = "Nintex.Workflow.Features, Version=1.0.0.0, Culture=neutral, PublicKeyToken=913f6bae0ca5ae12"
$class = "Nintex.Workflow.Features.WorkflowHistoryEventReciever"
$list.EventReceivers.Add($type, $assembly, $class)

However, if there is a template I can use (I don't think there is) or another means to duplicate the creation of these lists in powershell that would be ideal.

0 Kudos
Reply
jherschel
Nintex Newbie

Re: Create a Nintex Workflow History List in Powershell

I am also looking to do the same.  We have 20 different WF history lists that I would like to create on 10 different farms, but I guess I have to use the GUI....

0 Kudos
Reply
vacoder
Process Pupil

Re: Create a Nintex Workflow History List in Powershell

You can create these in PowerShell. I have only a few to do but you could do this in a loop as well:

$SPTemplate = $spweb.ListTemplates["Workflow History"]
$spweb.Lists.Add("LISTNAME1","LIST DESCRIPTION",$SPTemplate)
Start-Sleep -s 5;

$SPTemplate = $spweb.ListTemplates["Workflow History"]
$spweb.Lists.Add("LISTNAME2","LIST DESCRIPTION",$SPTemplate)

Start-Sleep -s 5;
     
$SPTemplate = $spweb.ListTemplates["Workflow History"]
$spweb.Lists.Add("LISTNAME3","LIST DESCRIPTION",$SPTemplate)

Start-Sleep -s 5;

Write-Host "WF History Lists added"
0 Kudos
Reply