InfoPath Solutions Blog

Blog about InfoPath and related technologies such as SharePoint, .NET, and other Microsoft software products.

Quick Tip: Select the latest date from a repeating table in InfoPath

Published on Sunday, 28 June 2009 by S.Y.M. Wong-A-Ton

In a recent article, I showed you how you can use the min() function, a hidden field, and formulas in InfoPath to select and display the oldest date that was selected from a date picker control in a repeating table.

You can easily change this solution to select and display the latest (newest) date that was selected from a date picker control in a repeating table.

All you would have to do is:

  1. Rename the minDate field to maxDate (just to keep things nice and tidy).
  2. Change the formula in step 13 of Selecting the minimum date in an InfoPath repeating table using formulas (no code) to:

    ../my:group1/my:group2/my:field1[../my:field2 = xdMath:Max(/my:myFields/my:group1/my:group2/my:field2)]

Extra tip:
The value of the latest date is stored in the maxDate field, so if your InfoPath form solution requires you to use this date elsewhere in the form, you can grab the value stored in maxDate.

And as mentioned in my previous article, this solution also works for browser-enabled InfoPath forms.

Trick: Create InfoPath forms using a SharePoint Designer workflow

Published on Wednesday, 24 June 2009 by S.Y.M. Wong-A-Ton

As you may already know, you can use either the Create List Item or the Copy List Item action in a SharePoint Designer workflow to create a SharePoint list item or document.

Create List Item advantages

A Create List Item action has the following advantages over a Copy List Item action:

  1. Create List Item returns the ID of the new SharePoint list item created, which you can use later on in the workflow to lookup the new item. Copy List Item does not return anything.
  2. If you use Create List Item, you can set the values of fields on the new SharePoint list item you create. If you use Copy List Item, you cannot set anything.

‘Create List Item’ does not work for InfoPath form templates

Create List Item works great on document libraries that are based on a Word or Excel template. But if you’ve ever tried Create List Item in a SharePoint Designer workflow on a SharePoint Form Library, you’d know that instead of creating a new InfoPath form, it creates a new copy of the InfoPath form template that is set as the default template on the SharePoint Form Library.

The difference is that when you create a SharePoint Document Library with a Word "template", SharePoint actually uses a Word document as the template on the document library, and not a Word template. This is not the case for a SharePoint Form Library where an actual InfoPath form template – and not an InfoPath form (document) – is used as the template on the form library.

So it makes sense that when you use the Create List Item action in SharePoint Designer, a copy of the InfoPath form template is created instead of a copy of an InfoPath form (document).

Workaround for using ‘Create List Item’ to create InfoPath forms

The trick to getting the Create List Item action to create a new InfoPath form in a SharePoint Form Library is to specify an empty InfoPath form as the default template on the SharePoint Form Library. And if you want users to be able to manually create an InfoPath form via the New button menu (in addition to forms automatically being created via a SharePoint Designer workflow), you must enable content types on the SharePoint Form Library.

In the following InfoPath-SharePoint-SharePoint Designer video tutorial, I’ll show you how you can create and deploy an InfoPath form template to a SharePoint Form Library, specify an InfoPath form as the default template on the SharePoint Form Library, and create a SharePoint Designer workflow to create new InfoPath forms in the SharePoint Form Library. Note: You could also deploy an InfoPath form template as a SharePoint site content type and apply a similar trick.

If you already know how to create and publish a browser-compatible InfoPath form template, you can fast-forward the video to the part where I specify an empty InfoPath form as the default template on the SharePoint Form Library; it starts around the 03:00 minute mark.

InfoPath Q&A: Can you put a repeating table in a repeating table?

Published on Tuesday, 23 June 2009 by S.Y.M. Wong-A-Ton

A visitor to my InfoPath blog asked:

Can you put a repeating table in a repeating table?

The short answer is: Yes, you can!

A repeating table is the visual representation of a repeating node in the data source of an InfoPath form template.

So if you want to add a repeating table in a repeating table, all you’d have to do is add a repeating node under the repeating table.

To do this:

  1. Add a repeating table to an InfoPath form template.
  2. On the Data Source task pane, right-click the repeating node for the repeating table (e.g. group2 if you did not change the node names), and click Add.
  3. On the Add Field or Group dialog box, type a name for the new node (e.g. group3), select Group as the Type, select the Repeating check box, and click OK.
  4. On the Data Source task pane, right-click the repeating node you just added (group3), and click Add.
  5. On the Add Field or Group dialog box, type a name for the new node (e.g. field4), leave Field (element) selected as the Type, and click OK.
  6. Repeat the previous 2 steps for as many fields as you want your second repeating table to have as its columns. Your final data source should look something like the following figure:

    The data source for a repeating table in a repeating table in InfoPath
    Figure 1. The data source for a repeating table in a repeating table in InfoPath.

  7. Select the repeating table that you put on the InfoPath form template in step 1 and delete it from the View, not from the data source.
  8. Drag the repeating node for the main repeating table (group2 in this example) from the Data Source task pane, drop it on the InfoPath form template, and select Repeating Table from the context menu that appears.

Your InfoPath form template should now look something like the following figure:
A repeating table in a repeating table on an InfoPath form
Figure 2. A repeating table in a repeating table on an InfoPath form.

Working with InfoPath