Today I’ll talk Workflow with InfoPath , especially the steps needed to attach the form to a task.
Step 1: Creating the module
First start by adding a module called “Forms” in our workflow in order to have a solution that looks like this.
Step 2: Add the InfoPath form to the module
Then create our infopath.
Nothing complicated here, the idea of this article is just to show how to integrate ourcustom form in a SharePoint task.
Once the form is done, a modification of the loan security is necessary, for this we must go the menu “File” – “Form Options”
Here we need to specify security at least on “Domain”.
Once this security in place, publish our form. We will publish it directly into our project.For this we must go to the tab publication and choose to publish on the network.
Select the location of our module “Forms” that we created in our workflow.
The next step is very important, we must empty the link to access our form!
This generates an error message when clicking next, click “OK” to ignore.
Let’s get to publish the form.
Once the form is published, get back to our Visual Studio solution and display all files by clicking the appropriate button.
Do a right click on our infopath to add it to the solution.
We can see in the Elements.xml file thath the form has been automatically added to the module.
Step 3: Edit the “feature.xml”
Now that infopath is added, we must deploy it to our SharePoint environment. For this we must add a specific receiver in the manifest of the feature.
ReceiverAssembly = "Microsoft.Office.Workflow.Feature, Version=184.108.40.206, Culture=neutral, PublicKeyToken=71e9bce111e9429c" ReceiverClass = "Microsoft.Office.Workflow.Feature.WorkflowFeatureReceiver"
That’s this receiver which will upload the infopath. We must also specify the following property so it knows where to look for forms.
<Property Key="RegisterForms" Value="Forms\*.xsn"/>
In the end we have a manifest that looks like this
Step 4: Edit the workflow’s “Elements.xml” file
We now need the ID of OOB content type “SharePoint Workflow Task InfoPath” in our definition.
<Workflow … TaskListContentTypeId="0x01080100C9C9515DE4E24001905074F980F93160" >
We must also specify the urn of our infopath. Caution! Make sure you have the urn of the published form!
For each form you can specify the ID here the example “<Task0_FormURN>” shows the ID 0, remember this ID we will use it right after!
Ultimately our file “Elements.xml” should look like this
Step 5: Changing the code to create the task.
In our workflow we can now specify the form that we use, for that we must change the properties of the task by giving the ID of the appropriate form, in our example we will give him the ID 0.
Our code looks like this
Step 6: Checking.
After deploying the solution we should find our form in the central administration more precisely in “General Application settings” – “Manage form templates”
And indeed it is present.
By starting our workflow when creating the task we can see our form!