Automatically add a new item to a SharePoint list using InfoPath 2007 and a custom workflow
Use SharePoint Designer 2007 to create a custom workflow that will add a new item to a SharePoint list whenever a new InfoPath form is added to a form library.
Problem
You want to design an InfoPath form that can be filled out through a web browser and add a new item to a SharePoint list as soon as the form has been saved to a Form Library.
Solution
Use SharePoint Designer 2007 to create a custom workflow that will add a new item to a SharePoint list whenever a new InfoPath form is added to a form library.
Discussion
You can accomplish this functionality as follows:
- Design an InfoPath browser-compatible form template as shown in the following figure.
Figure 1. InfoPath browser-compatible form template in Design mode.
The Main data source of the InfoPath form template resembles the following figure.
Figure 2. Main data source of InfoPath form template. - Publish the InfoPath form template to a server running InfoPath Forms Services, browser-enabled it, and promote
the employee field so that it will become available as a column of the
SharePoint Form Library for the form template.
Figure 3. Promoting the employee field through the Publishing Wizard in InfoPath. - Open SharePoint Designer 2007.
- Open the Site on which the Form Library of the InfoPath browser-enabled form template is located.
- On the File menu, select New, and then Workflow.
- On the first screen of the Workflow Designer dialog box, give the workflow a name, attach the workflow to the Form Library for your InfoPath form template, check Automatically start this workflow when a new item is created, and click Next.
Figure 4. The first screen of the Workflow Designer in SharePoint Designer 2007. - On the second screen of the Workflow Designer dialog box, add a Create List Item action to Step 1 of the workflow.
Figure 5. The second screen of the Workflow Designer where you can define steps for the workflow. - Click this list in the action you just added.
Figure 6. Defining actions in a workflow step. - On the Create New List Item dialog box, select a list (in our example, a custom list named Employee Submissions is used) to which you would like to add a new item whenever a new form is saved to the Form Library.
Click on a field from the list, Title in this case, and click Modify.
Figure 7. The Create New List Item dialog box where you can select a list to add a new item to and set the values for columns of the new list item. - On the Value Assignment dialog box, click the second button behind the To this value field. You will be assigning the value of the Employee
column of the Form Library to the Title column of the list.
Figure 8. The Value Assignment dialog box where you can specify the value for a column of the list item. - On the Define Workflow Lookup dialog box, leave the Source field on Current Item, select Employee from the Field drop-down list box, and click OK.
Figure 9. The Define Workflow Lookup dialog box where you can lookup a value from a column of the Form Library. - On the Value Assignment dialog box, click OK.
- On the Create New List Item dialog box, click OK.
- On the Workflow Designer dialog box, click Finish.
Now, whenever a new form is filled out and saved to the Form Library, the workflow you created and associated with the Form Library will be started, and the employee name that was saved within the form will be used to add a new item to the list you specified in the workflow.
Related InfoPath Articles:
- How to submit the rows of a repeating table in InfoPath to a SharePoint list
- How to use a SharePoint event handler and the object model to submit data from an InfoPath form to a SharePoint list
- How to use the SharePoint object model to submit data from an InfoPath browser form to a SharePoint list
- Programmatically add an item/event to a SharePoint 2007 calendar using InfoPath 2007 and .NET code
- Programmatically add an item with a Rich Text field to a SharePoint list using InfoPath 2007
- How to use a Visual Studio workflow to submit data from an InfoPath form to a SharePoint list
