SharePoint allows you to create instances of out-of-the-box workflows anywhere on the site.
Once those instances are created, when the workflow gets initialized on the item – your users get to fill in any of the required initiation parameters on the workflow initiation form. For out-of-the-box workflows such as Approval Workflow or Collect Feedback workflow, those are InfoPath forms.
There is a lot you can do with InfoPath forms, but there is a lot you can’t!
For example, a simple action of grabbing the value from a query string and rendering it to the user is just not available for workflow sourced InfoPath forms.
In fact, many standard InfoPath form features become unavailable as soon as your form is an initiation or association form for a workflow.
In my scenario, I have an approval workflow and I would like to display a link on the workflow form which will allow my users to view the source library where the item is located; the item which workflow runs on.
Now, in my case, the workflow Initiation form already passes a query string variable called Source which holds the link to a library. Although my scenario is simpler, you can use the approach outlined below for more complex scenarios.
I assume you already have an out-of-the-box approval workflow attached to one of the libraries. Run the workflow on the item to see a page similar to below:
As you can see, the InfoPath form in this page is hosted within IniWrkflIP.aspx, which is an out-of-the-box page we can’t modify.
We’ll create a new page and bind it to our workflow in just a moment.
Navigate to C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\TEMPLATE\LAYOUTS and find IniWrkflIP.aspx.
Make a copy of the file and call it IniWrkflIP_Modified.aspx, or whatever name you need, just don’t forget it.
Now, you can open up that page and start customizing it.
You can make virtually any changes to the page as long as you don’t try to convert some of it’s core properties, such as a page type.
You will notice that the page has the following two core components defined:
<InfoPath:XmlFormView id="XmlFormControl" runat="server" style="width:100%;margin-left:20px;" /> <SharePoint:FormDigest runat=server/>
If you like to deploy new workflow initiation form created in Visual Studio, instead of using a copy of the existing page, ensure you declare the InfoPath form view from above and any references that this view needs. Apart from that, you can customize the page however you need it.
In my case I will add the following link to the item folder, defined right under the :
<asp:Content ContentPlaceHolderId="PlaceHolderMain" runat="server">
The link will be defined based on the query string value as follows:
<%
if (List != null)
{
%> <a target="_new" href="<% SPHttpUtility.AddQuote(
SPHttpUtility.UrlPathEncode(Page.Request.QueryString["Source"],true),
Response.Output);%>">View items in folder</A>
}
%>
That’s it, I’ll save the file. Now it’s time to associate this new initiation page to the approval workflow on my site.
Open SharePoint Designer 2010 and open up the site where you attached the workflow to a list.
Under Site Objects click All Files, and in there navigate to click _catalogs/wfpub.
This is where all of the workflow templates reside for this site.
In our case, we’ll pick a Approval – SharePoint 2010. In there you will see several files including the InfoPath forms themselves.
Open the workflow configuration file as shown below, select Edit to edit the file:
In this file, you will find many of the initiation variables for out-of-the-box approval workflow, including the workflow initiation form defined as below:
<Initiation URL="_layouts/IniWrkflIP.aspx">
Change the name of the form from IniWrkflIP.aspx to IniWrkflIP_Modified.aspx, if that’s the name you specified for your page earlier.
Save the configuration file. That’s it, the workflow will now use your newly created initiation page.
Since you changed the template for approval workflow on the site, this is the version of the workflow that all new instances on the site will inherit. Templates for other sites remain intact.
You can also choose to make a copy of the approval workflow and localize your change even more.
Now when you run an instance of the approval workflow on the library where you modified the initiation form, your custom logic will execute as expected. In my case, it’ll show a link to a source library of the workflow item.
If you liked this post, you’re in for a treat when you read my SP2010 developer book.
Enjoy!

