Enhanced Workflow Initiation forms in SharePoint Designer

A powerful feature of WF technology is the ability to bind ASP.NET or InfoPath pages to workflow modules. These pages can play the role of Initiation, Association, Modification or Task forms. In SPD, you only get to play with Initiation, Modification and Task forms through the use of Initation variables, the Collect Data from User action and the Assign a To-do Item action respectively. However, only the Initiation form allows for any significant customization. When you assign Initiation variables in SPD,  a plain ASP.NET form is bound to your workflow. In the .xoml.wfconfig.xml file, you’ll see the declaration made within an <Initiation> element. The Initiation element will have a URL attribute that points to the relative URL of your Initiation form, which of course is in your workflow project folder.

A simple way to customize this form is to open it in SPD, select a control, then right-click and choose Properties. For a multi-line TextBox for example, you can set its Rows property to increase the default from 2 rows to say 6. You can set the Width property to 400px so it looks like all the other multi-line text boxes in SP. When you declare Initiation variables in your workflow, you only get 6 “information” (i.e. control) types to work with, which is limited. Obviously a User (people picker) type and a Lookup type would be pretty hot because you’re probably going to want to assign tasks to people and bind choices to list columns rather than hard-coding the choices the way SPD provides with its “Choice” type. Maybe you even want the option of using check boxes!

Radical thoughts indeed.

Of course you can use Visual Studio 2008 and build all of this, and more. Except for that one project where that is not an option. Like the one I’m on. Fortunately, making these kinds of changes is not rocket science. A few blog posts have been devoted to using asp:textbox with SharePoint:PeopleEditor, so I won’t waste time on that here.  Instead, how about inserting a list lookup field? Below is the Initation form source for a Text field I called “Investigation Next Steps”.





 First I replaced the asp:textbox with a SharePoint:DVDropDownList. The DVDropDownList control is generated when you use an Initation variable information type of Choice. However, the markup generated for a drop-down list control is going to include an asp:ListItem declaration for each of the hard-coded choices you entered when you added your Choice field to the workflow. Instead, we will change the binding of the control to reference a Text field in another list; in fact the standard “Title” field. The SPWorkflowDataSource that defines the binding back to the workflow initiation variable when a user clicks the “Start” button must be complemented with a SPDataSource in order for our drop-down list to be populated with the values from our “lookup” list. You can use SPD to insert a data source into your form, and probably like me will want to move the markup it generated to the <DataSources> node near the top. Here is the SPDataSource markup for reference.




Note that the SPDataSource attributes are not all shown above, but SPD will generate the right markup. There are two more changes to make. The first is to update the <DataFields> node to include your field; in my case this was the addition of the Title field. Then you will need to get the DVDropDownList DataSourceID attribute pointing to the data source we added. The DataTextField and DataValueField attributes simply reference the SP internal field name in the drop-down list data source; here again it was Title in my example.



As you can see below, the result looks exactly like the Choice information type when you define your initiation variable as a selection, but the big difference is that the display text and selected text values are sourced from another SP list.  



About generation12

I am a SharePoint/.NET consultant in the twin cities.
This entry was posted in Customization, Workflow Actions. Bookmark the permalink.

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s