views:

215

answers:

3

I'd like to collect some information from a user when they activate a feature on a site. Just like the WF Association form when you add a workflow to a list.

My particular scenario is a feature that creates a timer job that will do a weekly export of a document library as PDFs to a special staging database. When the feature is activated I'd like to ask the user for the connection string of the database, the source document library and the interval between updates.

A: 

I do not know of a way to do this when the feature is activated.

I think you would need to include an administration page in your feature to allow the user to enter the configuration information required, which the feature would then refer to. Perhaps you could also add a task entry with a link to the new admin page as a bit of a guide when the feature is activated.

Rhys Jones
A: 

I don't think you can interact with a user during feature activation. Feature events are fired server-side and you can't display a page to users in this process.

I would create a custom ASPX page that a user can visit to enter the connection string and other settings for your job. Once this page is submitted you can create a new instance of your timer job with the custom settings.

There's an example of how to do this on MSDN: Creating Custom Timer Jobs in Windows SharePoint Services 3.0, specifically in the section titled Deploying Custom Timer Jobs and sub-heading Custom Applications.

dariom
A: 

You can do this, but it's not the best idea. The problem is, you don't always know where your feature activation code is going to run. If you turn on the feature using stsadm, it will execute in stsadm.exe, not the web process. If you enable the feature using the web interface, then you can technically do a response.redirect to some custom page when the feature is activated. That custom page could then collect some information from the user and then activate the feature. Your feature activation code would have to check some web property or something to see if the user has supplied the necessary data, and if not, redirect the user to your custom page.

Pablo Gazmuri