Automatically add a new item to a SharePoint list using InfoPath 2007 and a SharePoint workflow
Use SharePoint Designer 2007 to create a SharePoint workflow that will add a new item to a SharePoint list whenever a new InfoPath form is added to a SharePoint form library.
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 SharePoint Form Library.
Use SharePoint Designer 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.
You can add an item to a SharePoint list using InfoPath and a SharePoint workflow:
- 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 SharePoint workflow a name, attach the workflow to the SharePoint 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 SharePoint workflow.
Figure 5. The second screen of the Workflow Designer where you can define steps for the SharePoint 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 SharePoint Form Library, the SharePoint workflow you created and associated with the SharePoint 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 SharePoint workflow.
Copyright: This article may not be used on web sites (whether personal or otherwise), copied, disseminated, altered, printed, published, broadcasted, or reproduced in any way without an expressed written consent of S.Y.M. Wong-A-Ton. The techniques demonstrated in this article may be used within any Microsoft InfoPath project. This article is provided without any warranties. Copyright for this article is non-transferrable and remains with the author, S.Y.M. Wong-A-Ton.
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
- How to use a Visual Studio workflow to submit data from an InfoPath form to a SharePoint list