Set the value in an InfoPath form from a SharePoint Designer workflow

Learn how to promote InfoPath form fields so that you can set their values through a SharePoint Designer workflow.

ADVERTISEMENTS

Introduction

If you want to access the values of InfoPath form fields from within a SharePoint Designer workflow you have to promote the InfoPath form fields, so that they become columns in the SharePoint form library in which the InfoPath form is stored.

If you want to set the value of an InfoPath form field from within a SharePoint Designer workflow, you have to do 3 things:

  1. Create a new or use an existing column on the SharePoint form library in which the InfoPath form is stored and on which the workflow runs.
  2. When publishing the form template in InfoPath, promote the field to the SharePoint form library column and select the Allow users to edit data in this field by using a datasheet or properties page check box.
  3. Set the value of the SharePoint form library column from within the SharePoint Designer workflow. This value will be written to the field in the InfoPath form.

You have the following 3 options when it comes to using a SharePoint form library column for InfoPath field promotion:

  1. When publishing the form template in InfoPath, let InfoPath create a new column on the SharePoint form library you are publishing the InfoPath form template to.
  2. In SharePoint, create a form library with an extra column to use for field promotion and then when publishing the form template in InfoPath, promote the field to that existing extra column you created on the SharePoint form library.
  3. In SharePoint, create a site column and a SharePoint form library, add the site column to the form library so that you can use it for field promotion, and then when publishing the form template in InfoPath, promote the field to that existing site column you added to the SharePoint form library.

This article discusses option 3.

Create a SharePoint form library with a site column

In this section you'll create a SharePoint form library and add a site column to it. The SharePoint site column will be used later as the column to promote an InfoPath form field to.

To create a SharePoint form library and add a site column to it:

  1. In SharePoint, create a new site column named IPSiteColumn and of the type Single line of text. Consider the scoping rules of site columns when you are choosing the SharePoint site on which to create the site column.
  2. Go to the site on which you want to create the SharePoint form library.
  3. On the Site Actions menu, click Create.
  4. On the Create page under Libraries, click Form Library.
  5. On the New page, type a Name for the SharePoint form library, and click Create.
  6. On the Settings menu of the SharePoint form library you just created, click Form Library Settings.
  7. On the Customize page under General Settings, click Advanced settings.
  8. On the Form Library Advanced Settings page, select Display as a Web page, and click OK.
  9. On the Customize page under Columns, click Add from existing site columns.
  10. On the Add Columns from Site Columns page, select Custom Columns from the Select site columns from drop-down list box, select IPSiteColumn in the Available site columns list box, click Add to add the site column to the Columns to add list box, and click OK.

The SharePoint form library should now contain a column named IPSiteColumn to which you can promote an InfoPath form field.

Create an InfoPath browser-compatible form template

For demonstration purposes, you must create a simple InfoPath browser-compatible form template with a Text Box control named field1 on it.

To publish the InfoPath form template to SharePoint and promote the field1 InfoPath form field to the IPSiteColumn you previously added to your SharePoint form library:

  1. In InfoPath, on the File menu, click Publish.
  2. On the Publishing Wizard, select To a SharePoint server with or without InfoPath Forms Services, and click Next.
  3. On the Publishing Wizard, type the URL to the SharePoint site where the form library is located, and click Next.
  4. On the Publishing Wizard, select Document Library, and click Next.
  5. On the Publishing Wizard, select Update the form template in an existing document library, select the SharePoint form library you created previously in the list of Document library to update, and click Next.
  6. On the Publishing Wizard on the screen where you can make columns available on SharePoint sites and in Outlook folders, click Add.
  7. On the Select a Field or Group dialog box, select field1, select Custom Columns from the Site column group drop-down list box, select the IPSiteColumn site column from the Column name drop-down list box, select the Allow users to edit data in this field by using a datasheet or properties page check box, and click OK.

    Promoting an InfoPath form field to a SharePoint site column that has been added to a SharePoint form library
    Figure 1.Promoting an InfoPath form field to a SharePoint site column that has been added to a SharePoint form library.

    Click OK to accept the warning that is displayed.

  8. On the Publishing Wizard, click Next.
  9. On the Publishing Wizard, click Publish.
  10. On the Publishing Wizard, click Close.

Create the SharePoint Designer workflow

To set the value of the field1 InfoPath field from within a SharePoint Designer workflow:

  1. In SharePoint Designer, create a SharePoint Designer workflow, attach it to the SharePoint form library which contains your InfoPath forms, set the workflow to automatically start when a new item is created, and click Next.
  2. On the Workflow Designer on the screen for Step 1, click Actions, and select More Actions from the drop-down menu.
  3. On the Workflow Actions dialog box, select Core Actions from the category drop-down list box, select the Set Field in Current Item action, and click Add.
  4. On the Workflow Designer on the screen for Step 1, click field in the text for the action, and select IPSiteColumn from the drop-down menu that appears.
  5. On the Workflow Designer on the screen for Step 1, click value in the text for the action, and select or type whatever value you want to set the InfoPath form field to.

    Step 1 of a SharePoint Designer workflow to set the value of a promoted InfoPath form field
    Figure 2. Step 1 of a SharePoint Designer workflow to set the value of a promoted InfoPath form field

  6. On the Workflow Designer, click Finish.

Test the SharePoint Designer workflow

You should now have a fully functional form so that when you create a new InfoPath form and store it in the SharePoint form library, the SharePoint Designer workflow is kicked off and the value of the promoted InfoPath form field is set by the workflow.

If you then open the InfoPath form, you should be able to verify that the SharePoint Designer workflow was able to set the value of the promoted InfoPath form field.

 
 Subscribe for updates via RSS or Email

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.

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 5: Integrating InfoPath with Excel and Excel Services


Related InfoPath Articles:

ADVERTISEMENTS

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