Haaron Gonzalez Rotating Header Image

InfoPath

Formulas to get the first and last row on a repeating table in InfoPath

You know, you wake up knowing that is going to be a wonderful day working for a customer with the software products you love. During today on-site support session, you found out that is needed to write some good old XPath formulas on an InfoPath form.

There is a repeating table with the columns necessarily to describe travel information like Departure Date, Return Date, City, you named and the requirement was to expose the initial Departure Date and the last Return Date of the entire trip, so, what do we mean with entire trip? I maybe start a trip from San Diego to Mexico City, and then another trip from Mexico City to Seattle and then from Seattle to Las Vegas. Clearly, the Departure Date and Return Date are not associated with just one row “trip” in the repeating table because I have at least more than one row for describing all the trips.

The data structure of the repeating table is:

 

 

structure

So, here are the formulas to get the first and last row on a repeating table.

../my:TravelInfo/my:TravelInformation[count(preceding-sibling::my:TravelInformation) = 0]/my:DepartureDate

../my:TravelInfo/my:TravelInformation[count(following-sibling::my:TravelInformation) = 0]/my:ReturnDate

Fortunately, the approach work as a charm. No C# code saved the day today. Pure old good XPath did it. InfoPath, you are definitely the sunshine of my love, especially now that you will be supported until 2026 baby.

 

Wake Up, Lazarus

You will not believe, but I’ve been so busy that didn’t had chance to write a post about the Release Candidate of SharePoint Server 2016 announced by Bill Bear on Jan 20, 2016. Now we can get more serious on evaluating SharePoint Server 2016 for our production environments. If you are interested, please take a look on this announcement.

SharePoint Server 2016 and Project Server 2016 Release Candidate available

Also, please read Dan Holme point of view on the RC and SP16, it has a valid point!

NOTE: Notice that InfoPath 2013 and SharePoint Designer 2013 will match support lifecycle for SharePoint Server 2016, running until 2026 meaning that we can still support our customers that have InfoPath Forms and SharePoint Designer Workflows.

spc14-infopathfuneral

How to create hyperlink that open InfoPath client software a.k.a InfoPath Filler

Today was my second on site visit of the year and during my visit I was requested to fix one of the most frequent issues you will find when building workflow based solutions using SharePoint Designer and InfoPath client forms.

So an email activity in the Workflow Designer has a Hyperlink that it supposed to load a InfoPath form instance when the user clicks, in this scenario, the InfoPath solution runs in InfoPath Form Filler so when the users clicks the hyperlink it should load InfoPath Filler client application.

Turns out that using Encoded Absolute URL field that has the actual URL address of the form instance inside of the <a href=””> tag is not enough and will cause user to open Internet Explorer and try to load the form with InfoPath Form Services but because the form was designed to run in InfoPath Filler an exception will happen and users will be NOT so happy.

The solution is pretty simple; we just need to change the URL we will use to invoke InfoPath Filler to load inside of the anchor tag. Also I recommend using the Hyperlink button available in the email body of the message.

Hyperlink control in Send Email

 

The URL should have the following Workflow and Current Item variables:

  • %Workflow Context:Current Site URL% will get the URL of the current site where the workflow is running
  • /layouts/FormServer.aspx is a system web page that is used by InfoPath Form Services to render the form in the browser
  • XmlLocation is a query string variable that will tell to FormServer.aspx where the form data is located and it will use to load the form in the browser. We use the Workflow variable % Workflow Context:Current Item URL% to get the XML file
  • ClientInstalled = true is another QueryString variable that will thell the FormServer.aspx page that the form should be loaded in the client software, in this case our beloved InfoPath Form Filler
  • Source query string variable is used by the FormServer.aspx page to redirect the browser to the URL we want to load when we close the form, this work on InfoPath Form Services, nothing to do to InfoPath Filler
  • DefaultOpen is another query string variable that tells formserver.aspx how to load the form

Here you can see official information about the InfoPath parameters

So the definition of the hyperlink data is:

 

String concatenation to generate URL

The result will be something like this:

http://intranet.mycompany.com/sites/IT/finance/_layouts/FormServer.aspx?XmlLocation=http://intranet.mycompany.com/sites/IT/finance/IT Project/ITP20151030200643.xml&ClientInstalled=true&Source=http://intranet.mycompany.com/sites/IT/finance&DefaultOpen=0

So remember, red text is going to be generated by SharePoint Designer Workflow Variables, Bold text is going to be hard coded in the concatenating string.

Good luck!

Discover SharePoint Web Services methods and parameters and feel nostalgic about it

This is not the first time that a customer has an issue with SharePoint Web Services “. asmx” and InfoPath Forms that I need to quickly spot and fix. Of course SharePoint Web Services work as a charm, but sometimes the problem comes more to InfoPath forms how they consume the services SOAP response and request headers. Yes, I’ve said InfoPath. A lot of customers still work and use InfoPath forms, they created and automated HR or IT process using these wonderful technologies and we, support engineers need to support. A lot of customers still have a dependency on InfoPath.

Today I want to share a resource that is not the first time that help me identify the problem and that is .NET Web Service Studio, this application is a .NET client application that you can use to discover the Methods of a web service and review the SOAP request and response parameter.

Very handy to start understanding a web service. So because this is like the third time I’ve used these tools to start supporting an InfoPath Form here you have it:

Just go to WebServiceStudio a codeplex, hit Download and enjoy the ride. There is some nostalgic feeling working and using the tool.

Just look the icons, don't you feel little nostalgia?

Just look the icons, don’t you feel little nostalgia?

Deploy InfoPath Forms with UDCX files in multiple SharePoint farms

Probably you follow the best practices when building InfoPath Forms solutions. You know, there is a recommendation to use UDCX files a.k.a universal data connection files to describe the connection details of a data source. That is all good stuff, the point that I want to share today, is how to deal with InfoPath Forms that have data connection files that need to be deployed to a different farm like from DEV, QA, UAT and PROD farms.

Of course each farm as a different DNS, for example:

  • Development Box: http://myspdevbox1
  • Test Farm: http://preportal.mycompany.com
  • Production Farm: http://portal.mycompany.com

So, my InfoPath form in development will have a reference to the UDCX file pointing to DNS: http://myspdevbox1 and to site collection like /sites/IT, the Site Collection part is relative, that mean that as long every farm has the same path everything should work, but, of course every farm will not have the same DNS.

How we can change the Form Template to point to a different DNS and ensure it points to the right data connection files?

Here the steps:

  1. Open the form and select File – Publish, from the Export section, click Export Source Files, then save the form files in a folder
Export the form as Source Files

Export the form as Source Files

  1. Using Windows Explorer, navigate to the folder, look for manifest. xsn file and open with Notepad
Open manifest.xsn in Notepad

Open manifest.xsn in Notepad

  1. Find your existing DNS like http://preportal.mycompany.com and replace with the new farm DNS like http://portal.mycompany.com
Find and Replace in Notepad

Find and Replace in Notepad

  1. Replace all your DNS entries and save the file
  2. Open the manifest.xsn with InfoPath Designer and save the template with a proper name different from manifest.xsn
Open the manifest.xsn in design mode

Open the manifest.xsn in design mode

  1. Publish your new InfoPath form template to your new farm, you will notice that in the Publishing Wizard dialog box already will have the new DNS
  2. Now you can test.

Remember, you also need to edit your data connection files to point to the proper DNS and they need to be stored in the same relative path.