InfoPath – Limit a Repeating Section

I had a requirement in one of my forms to limit the number of repeating sections to be displayed.

I read through some blogs that gave me some ideas on how to increment the row number which was very helpful and got me on the right track. Check them out when you have a moment:

http://nickhurstblog.com/2011/08/26/infopath-2010-repeating-table-incremental-row-number/

https://alecpojidaev.wordpress.com/2010/01/07/accessing-previous-rows-in-repeating-group-for-browser-enabled-forms/

Basically, you will need to auto increment a number field when a new section is added to the form. There is a very simple way to handle this and it only takes one rule and one field.  To do this, follow these steps.

  1. Create a new interger field and add to your repeating group.  For this example, we will name it Count
  2. Right click on Count and click properties, then click the fx button.
  3. Check the box to Edit XPath (advanced) and enter in the following formula: count(../preceding-sibling::*) + 1
  4. Click Verify Formula then click OK
  5. Make sure ‘Refresh value when formula is recalculated’ is checked
  6. Click OK
  7. If you have not added the repeating section to your form, do this now
  8. Preview your form to make sure that everything is working properly
  9. Click on the repeating section and then click ‘Manage Rules’ in the ribbon
  10. Add the following formatting rule
    1. For the Condition:
      1. Field: Count
      2. is greater than or equal to 5
    2. Check ‘Don’t allow users to insert or delete this control’
  11. Preview your form

You should now see that you can only be able to add a total of five repeating sections.  You can change this number to limit what you actually need.

I have included an example template that demonstrates how this works.  Please note that this form was created in InfoPath 2013 and is a browser based form.

LimitRepeatingSection

Enjoy and Stay Salty!

 

InfoPath – Multiple attachments in one web based form

Attachments in InfoPath are great.  The only issue with this, is that you can only attach one file to your form at a time.  In order to get a around this, you will need to add a handy dandy repeating section.  I have also added a count box to show how many attachments have been added to your form.  You also will have the ability to hide all of your attachments.  That’s where the count comes in handy.

I like to use this hide function for my attachments especially when I have a form that goes through an approval process.  I have attached a starter form using these controls.  The ‘attCount’ field has a default value set to count how many controls have been added to your form.  There is one rule set for the repeating section to hide it the ‘hideAttachments’ is set to ‘TRUE’.

I saved the form in a 2007 web based format.  You should be able to open in all versions of InfoPath 2007 – 2013.

Download Multiple Attachments Form

Stay Salty!

InfoPath – Shorten url for browser based forms

In the world of InfoPath, you may have noticed the the url for an open form is crazy big!  I ran into a problem in the past when I ran out of space in the url.  Sometimes this happens if the form is nested a couple of levels down in a site.  Whenever you open a new form in the browser, your url will look like the following:

https://www.yoursite.com/depts/test/_layouts/15/FormServer.aspx?XsnLocation=
https://www.yoursite.com/depts/test/newhiresur/Forms/template.xsn&SaveLocation
=https%3A%2F%2Fwww%2Eyoursite%2Ecom%2Fdepts%2Ftest%2Fnewhiresur
&ClientInstalled=true&DefaultItemOpen=1&Source=https%3A%2F%2Fwww%2
Eyoursite%2Ecom%2Fdepts%2Ftest%2Fnewhiresur%2FForms%2FAll
Items%2Easpx

You can shorten the above by removing all of the items in bold.  It will look like this once you have finished:

https://www.yoursite.com/depts/test/_layouts/15/FormServer.aspx?XsnLocation=
/depts/test/newhiresur/Forms/template.xsn&SaveLocation=%2Fdepts%2Ftest%
2Fnewhiresur&ClientInstalled=true&DefaultItemOpen=1

As a best practice, I do this each time I have to setup a link to an InfoPath form.   This way, I keep my urls short and will not have any issues of running out of url space.

 

Stay Salty!

 

InfoPath – Add Sequential Dates

In the past, I needed to add a date sequentially on insert of a repeating table.

I found a post by S.Y.M Wong-A-Ton that helped me achieve this.  Here is a link to that post: http://www.bizsupportonline.net/infopath2007/automatically-populate-repeating-table-infopath-sequential-dates.htm

If you are working on anything InfoPath, this site is a GREAT resource.  I highly suggest that you check it out.

I have included a sample form for you to download.  You can add this control to any of your existing forms.  Here are the steps for re-creating this from scratch

  1. Add a group
  2. Add a repeating group
  3. Add two fields:  date picker and text fieldField 1 (date picker control)
    Field 2 (text control)
  4. Right click on field2 and insert the following statement in the value box
    preceding-sibling::group2[1]/field1

Make sure to change the field names if different than the ones in your form.

Here is the form you can download by clicking.  AddSequentialDates

InfoPath 2007 – Contact Selector Shows Red X

On rare occasions, I have ran into this and I always seem to forget what to do then this happens.  It’s actually quite simple.  All that you need to do is run office diagnostics.  First things first, close InfoPath.  Then, follow the directions for your version of Windows.

Windows 7

  1. Windows
  2. Control Panel
  3. Programs and Features
  4. Find your Office installation and right click on it
  5. Click Change
  6. Click Repair

Windows XP

  1. Start
  2. Control Panel
  3. Add or Remove Programs
  4. Find your Office installation and right click on it
  5. Click Change
  6. Click Repair

Once the repair has completed, open InfoPath and check your form.  The contact selector should be working fine now.

 

InfoPath 2007 – Populating from data/dropdown info from SharePoint lists using XML form data

This article applies to InfoPath 2007 only as 2010 and 2013 no longer have this limitation.

At some point during your career, you will need to connect to a SharePoint list to retrieve information for a drop down list.  This process has changed since 2007 but I thought that I would go ahead and share this.  InfoPath 2007 only reads the data in the list on how it was entered in to SharePoint.  For example, if you uploaded a list of addresses in no particular order, this is the way that InfoPath reads it.  Now, what if you would like to see your selection sorted alphabetically?  You will first need to either modify your existing view of  the list you will be using as a data source or create a new view.

***Note: In order to see the entire list, the view must be changed to show more than the default 100 records

InfoPath will not recognize this view and you cannot sort lists when forms are browser based. As stated earlier, it only sees the original layout. In order for InfoPath to populate the drop down list with the correct format you will need to do the following:

  1. Double click the drop down list that you want to add the data connection to. This box will pop up. Follow the steps in the remaining screenshots to step 4. Then follow further directions.
  2. 1  
  3. 2  
  4. Go to the site that contains your list that you want to pull your data from.
    Example: http://yoursite.com/subsite/ and open the list
    Click “Settings” on the taskbar of the list then click “List Settings”
    Click on the view that you would like to use located at the bottom of the page
    When the page opens, highlight the entire address bar and press Ctrl+C
    Open a text editor (Notepad) and press Ctrl+V. Your address will look something like this:http://yoursite.com/subsite/_layouts/ViewEdit.aspx?list=%7B9C833605%2D8911%2D4B69%2D84AA%2D24DF8775735F%7D&View=%7B734A3221%2D4E03%2D4B10%2D9BE9%2D857775EBF802%7D&Source=%252Fdepartments%252Fhealth%252F%255Flayouts%252Flistedit%252Easpx%253FList%253D%25257B9C833605%25252D8911%25252D4B69%25252D84AA%25252

    D24DF8775735F%25257D

  5. You will need to modify this address to provide the form with the correct XML values. To do so, either type or copy/paste from this address the following.
    Make sure to replace yoursite.com/subsite with your own variables:http://yoursite.com/subsite/_vti_bin/owssvr.dll?Cmd=Display&List=%7B9C833605%2D8911%2D4B69%2D84AA%2D24DF8775735F%7D&View=%7B734A3221%2D4E03%2D4B10%2D9BE9%2D857775EBF802%7D&XMLDATA=TRUE
  6. The %, letter, number string represents the {GUID} for the page. The &XMLDATA=TRUE converts the page into an XML format that the InfoPath form can read. The &View and string represents the {GUID} for the “AllItems View”
  7. Once you have modified the url, copy and paste it into the next setup page. Close the text editor and do not save when it asks. Follow the steps in the remaining screenshots.
  8. 4  
  9. 5  
  10. 6  
  11. 7  
  12. 8  
  13. 9  
  14. Save the InfoPath form and publish it to the SharePoint site.  Next, login to SharePoint and go to the form that contains this data connection. Verify that the information is displayed in the correct order.

This little trick will save you all kinds of headaches if you rely on information supplied by your SharePoint lists.

InfoPath – Difference between days

I had a request for a form to count the number of days between two date pickers as one of it’s functions.  All that you need to make this happen is add two date picker controls and one text field to display the count.  I have included an InfoPath sample form that explains this in detail and should provide you with the knowledge to add something like this to one of your forms.

I originally found this form on the following site when I faced this issue: https://alecpojidaev.wordpress.com/2008/12/30/infopath-codeless-programming-walkthrough-2/

Alec Pojidaev has many great techniques for using no code solutions which I am a big fan of.  I suggest you check out his site to see all of the advanced features he has laid out.

Click the link below to download the zip file.

DifferenceBetween2Days

Retrieve Active Directory Information from the User Profile Service – part 1

Very often in InfoPath, I need to query Active Directory for certain pieces of information just so that I can have some type of functionality within my forms.  One of the most used and easiest forms of this is the user profile service.  I use this to my advantage to query e-mail addresses, user account info, etc.  Also, this is a must if you use the Contact Selector control from within InfoPath.

Follow these steps and you will be on your way.  Stay tuned for part 2 as I will be showing how to query the display name for AD accounts in a later post.

GetUserProfileByName Data Connection

  1. Create a new data connection to “Receive Data” from “Web Service”.
  2. Click Next.
  3. Type in the following url: http://yoursite.com/_vti_bin/userprofileservice.asmx?wsdl
  4. Click Next
  5. Select “GetUserProfileByName
  6. Click Next
  7. Leave the default value for Parameter
  8. Click Next
  9. Leave box unchecked

10. Click Next

11. Name the connection “GetUserProfileByName”

12. Check the box to automatically receive data

13. Click Finish.

14. The wizard will look like the images below.

 WebService

DataConnection

Weird option button behavior

Just received a message that one of my forms was not behaving properly.  It seems that when someone seleted one of the option buttons in a set, more than one option would get selected.  I said to myself, “This is not possible.  You can only select one option at a time.”

Well, come to find out, I was right except for one minor detail.  When I double clicked on one of the buttons in design mode to show me the value, I noticed that it had the same value as another option button.  So whenever one was selected, both would populate and give the incorrect value.  I changed the value and now all is well.

Moral of the story……make sure to triple check your values.  It will cause a lot less grief down the road.