Add process to newly created site/list

  • 12 March 2010
  • 5 replies
  • 0 views

Badge +1

Hello,


I am trying to work out if I can add a new process to a list that is created from another K2 process.


Basically I have an infopath form that fires a site creation process, it uses a custom site definition with some stapled features to create some lists and libraries.


What I want is to be able to have a process attached to these lists after they are created. If I try to create a new sharepoint list item event, it asks me for the site and list I want to add it to, but these obviously do not exist yet. 


Can this be done?


Thanks


5 replies

Userlevel 4
Badge +14

This is a long shot but you can try using IPC’s, in the parent create the list and maybe write the list name to a datafield, and then in the child use the datafield to reference the list.


vernon

Badge +1

Sorry what I was after is for the event receiver to actually be tied to that new list. Is it possible to add a K2 process event receiver through code to a list or is there much more K2 stuff that goes on in the background.

Badge +5

A couple of things going on here.  First, if you deploy an event based process to a SharePoint site, save the site as a template, and then create a new site based on that template, K2 process instances will be started based on the same events in the new site.  To try this yourself, take a dev box and hook up a K2 Events based process to the 'Calendar' list.  Deploy the process and create a new calendar item.  A new K2 instance will start.  Next, save the site as a template, create a new site off that template, then add a new calendar item to the new site's calendar.  A new K2 instance will start.


The other piece to this puzzle is manipulating the lists/list items within the newly created site that doesn't exist when the workflow is first started.  This is easily handled by K2 as well by asking you for 'Design Time' values for the objects you want to manipulate.  Let's say you want a workflow to create a new site based on your template and then want to add an item to a list in the new site.  You would use a process level data field or SmartObject property to store the URL for the new site and then use that field in the wizard.  It will prompt you for design time values where you'll specify a current site that has the same structure.  Now you can run through the wizard(s) to specify what you want to do but the site/lists/etc. that will actually be modified will be loaded at runtime for the new site.

Badge +1

Thank you Erice,


Just one question, could I save the list/library as a template rather than the whole site? And would I get the required information if I use something like SPSource on the list. The reason being is that I have a custom site def already, with some feature stapling to create lists and libraries and it would be good if I could just incorporate this library in my custom feature.


Thanks

Badge +5

I haven't tested that, but I'm 99% sure that it won't work because the K2 events are configured at the site level rather than the list level.  This is similar to other non-K2 event monitors that listen for events that fire within a site.


I'm not 100% sure if you can do this with blackpoint (definitely can with blackpearl), but you should be able to write an assembly or web service that uses MSBUILD to publish the workflow whenever you need to.  You could use the 'Reference Event' within the workflow to call that service/assembly.  I have used MSBUILD in the past to deploy workflows and you can pass in some settings on where to deploy to.  I know that K2 API calls are limited with blackpoint, but I don't think you would need any of that when using MSBUILD alone.  It might be worth investigating if not being able to create a new list off a template is a deal breaker.   It might be easier though to just deploy the workflow to your custom site and then recreate the template but I might not have enough information for that to be viable.

Reply