tags:

views:

408

answers:

3

I'm aware of the event receivers on a list for items added etc. However, I have not found a way to fire code upon the creation of a list.

What I'm trying to do is associate a workflow with a list when the list is created (by the user through the UI).

Anyone any ideas?

thanks.

A: 

I usually deploy an extra view page which is set to the default view. When the user creates the list he will be sent to the viewpage which contains the setup in code behind. The view page then calls a method ive created, which changes the default view, removes the setup view and change any navigation node pointing to the setup view.

JMD
That's quite an interesting approach! Thanks!
Donaldinio
+3  A: 

There are a couple of routes you can take...

You can write your own list definition where you have defined the workflow association - That way all lists created based on your list definition, will contain your workflow on default.

Or... depending on your workflow... write an EventReceiver your attach to all lists of the type you wish to attach your workflow to (can easily be achieved tru a feature) and have your event receiver associate the workflow when the first item is added.

or you can associate the workflow to the contenttype used in the list (your own contenttype you attach to your own list definition or a default SharePoint contenttype)

I don't know the rest of your solution, so it's defficult for me to suggest the best solution for you.

What I (almost) always do, is write my own list definition - That way I can avoid problems like this, now or in the future.

Brian Jensen
Thanks Brian. I'll likely associate the workflow in the list template. Although I'm thinking it might have been better to have the workflow be attached to any library, and just create the required elements (columns, views, etc) on initialization.
Donaldinio
+1  A: 

There is probably no perfect answer to this question because there is no list added event receiver (if memory serves me correct).

I don't know if this is the case, but if you really just needed to register an itemadded (or updated, deleted, etc.) event to any new list, I believe you can register the those events at the site (SPWeb) level and they will fire on any new lists created.

Kirk Liemohn