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.

ADVERTISEMENTS

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 SharePoint Form Library.

Solution

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.

Discussion

You can add an item to a SharePoint list using InfoPath and a SharePoint workflow:

  1. Design an InfoPath browser-compatible form template as shown in the following figure.
    InfoPath browser-compatible form template in Design mode
    Figure 1. InfoPath browser-compatible form template in Design mode.

    The Main data source of the InfoPath form template resembles the following figure.
    Main data source of InfoPath form template
    Figure 2. Main data source of InfoPath form template.
  2. 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.
    Promoting the employee field through the Publishing Wizard in InfoPath
    Figure 3. Promoting the employee field through the Publishing Wizard in InfoPath.
  3. Open SharePoint Designer 2007.
  4. Open the Site on which the Form Library of the InfoPath browser-enabled form template is located.
  5. On the File menu, select New, and then Workflow.
  6. 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.
    The first screen of the Workflow Designer in SharePoint Designer 2007
    Figure 4. The first screen of the Workflow Designer in SharePoint Designer 2007.
  7. On the second screen of the Workflow Designer dialog box, add a Create List Item action to Step 1 of the SharePoint workflow.
    The second screen of the Workflow Designer where you can define steps for the workflow
    Figure 5. The second screen of the Workflow Designer where you can define steps for the SharePoint workflow.
  8. Click this list in the action you just added.
    Defining actions in a workflow step
    Figure 6. Defining actions in a workflow step.
  9. 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.
    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
    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.
  10. 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.
    The Value Assignment dialog box where you can specify the value for a column of the list item
    Figure 8. The Value Assignment dialog box where you can specify the value for a column of the list item.
  11. 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.
    The Define Workflow Lookup dialog box where you can lookup a value from a column of the Form Library
    Figure 9. The Define Workflow Lookup dialog box where you can lookup a value from a column of the Form Library.
  12. On the Value Assignment dialog box, click OK.
  13. On the Create New List Item dialog box, click OK.
  14. 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.

 


Related InfoPath Articles:

 

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. 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.

InfoPath 2013 Cookbook: 121 Codeless Recipes for Beginners

InfoPath 2013 Cookbook 2: 121 Codeless Recipes for SharePoint 2013

InfoPath 2010 Cookbook: 101 Codeless Recipes for Beginners

InfoPath 2010 Cookbook 2: 101 Codeless Recipes for SharePoint 2010

InfoPath 2010 Cookbook 3: 101 Code Recipes for C# Developers

InfoPath 2010 Cookbook 4: 101 Code Recipes for VB Developers

InfoPath 2010 Cookbook 5: Integrating InfoPath with Excel and Excel Services