So you’re a fan of InfoPath, you use it every day when designing your forms, you even literally dream of it sometimes – you just love InfoPath… but there are times you’re having “InfoPath nightmares” when you can’t make things work because of limitations, or – bugs! Well, the world isn’t perfect, there’s got to be at least one hole or a number of cracks somewhere, right?
In this blog post, we’ll try to patch some of those “cracks” to at least lessen your InfoPath nightmares.
Here’s a list of the top 10 workarounds I have in mind:
1. Copying repeating data from a secondary data source into the main data source?
One thing that you can’t easily do in InfoPath is to copy repeating data from a secondary data source – like a SharePoint list – to the main data source. This is an important necessity, because the data from secondary data connections does not get saved in the resulting XML data file of a submitted/saved InfoPath form. Read more…
Dealing with more complex repeating data structure? Here’s the solution…
2. Concatenating lists of values?
Use the double-eval trick. Let’s say you want to build a list of email addresses in your form, maybe for workflow purposes; or simply for sending the form to a dynamic list of people via email. You want something like this:
For the example shown above, we’ll have this for our schema:
The EmailAddresses field will contain the formula that will build the list of email addresses. The formula should look like so:
Here’s the complete XPath to that formula:
substring(xdMath:Eval(xdMath:Eval(../my:UserList/my:User, 'concat(@my:email, substring(";", 1, string-length(@my:email)), " ")'), ".."), 1, string-length(xdMath:Eval(xdMath:Eval(../my:UserList/my:User, 'concat(@my:email, substring(";", 1, string-length(@my:email)), " ")'), "..")) - 2)
3. Dynamically adding rows to repeating data?
Here again, qRules makes this easier for you – you can write your own code, yes; or even hire a developer, but qRules just makes it a lot simpler (and cheaper!) for you. You can use the command called Insert which allows you to add a row, or any number of rows, at any position in your repeating table. The qRules User Guide which comes with the installation files should help you get started with using this command.
4. Keep form state values out of the main data source
One of the best practices when designing InfoPath forms is making sure that there are no fields in your main data source that don’t really store data. Anything that’s being used to control the logic in your form but doesn’t necessarily store values should go into a secondary data source such as an XML file. For example, you want to check whether the user opening the form has edit permissions. You could then have a node in your secondary XML file called “CurrentUser”. The logic in your form will populate that CurrentUser node either via an Active Directory web service or SharePoint’s UserProfileServices method, or simply via the username() function; and then can have a rule check whether the value is the same as that of the form submitter, or the approver, or what-have-you. Since the value of the current user will always change, it can go into your secondary XML data source.
5. Submitting repeating data to a SharePoint list?
Ok, you can use SharePoint list forms – but list forms actually have a flat data structure, i.e. non-repeating. If you want to submit multiple products in one order, the list item for that order will either keep a merged list of products, or just the first/last product which isn’t really helpful especially if you want to report on your data. The SubmitToSharePointList qRules command features the ability to submit data from an InfoPath form to the SharePoint list it has been mapped to. It also allows updating of an item in the SharePoint list from the form. The latest version even allows you to submit to different lists – so in our example, we can now keep a separate list of orders, and a separate list of products with reference the corresponding order.
- Watch this YouTube video to learn more and see its powerful features in action
- Here’s a blog post that has detailed steps to walk you through setting up your form to submit repeating data to list forms using the qRules command
6. Conditional hiding disabled?
You want to hide your Date picker control or your radio buttons, check boxes, or a hyperlink at certain conditions – surprised to find out that the “Hide this control” option is disabled? Easy fix: place the control in a section and add your conditional formatting to that.
7. Always give your forms unique names
You can do this using fields that you know will always be unique, but what if there are none? Yes you can concatenate the company name and the customer name, but you’re still not 100% assured that it will forever be unique. A company can have two John Smiths after all, right? So aside from concatenating field values, you can also add the current date and time by using the now() function which includes seconds in the timestamp. If you require more than that, you can use qRules’ GetFullDateTime command which returns milliseconds – now that will be sure to be unique!
8. Unable to use Digital signatures?
9. White space?
You thought you’ve set everything on the canvas to lay out nicely in the browser and/or client, but the white spaces just won’t go away! Aside from making sure that you’ve set row heights, paddings and margins to zero, you also need to remove section borders. Don’t be tricked – you’ll think that all the new section controls that you add on your form (whether they be repeating or non-repeating sections) don’t have borders? They do! Turns out that by default, sections have ‘invisible’ outline borders – so update them and select ‘None’ from the border presets.
10. Need your dropdown list box to display concatenated values?
You’d like your dropdown list box to display the customer’s Full name but you only have the First and the Last name values separated in your data source. Of course, if you have full control of the data source, you can easily make this happen by using another field that concatenates the strings you’d like to display. Otherwise, the other option would be to manually update the .xsl file. If you export your form’s source files and inspect the XSLT for your drop-down list box in the view’s .xsl file, you’ll see something like this:
You can modify the last select value (which is actually the displayName) to be the concatenated formula, like so:
Learn More
Qdabra offers short video tutorials and in depth how-to hands-on-labs. Check out the following links:
- YouTube Video highlighting the above techniques:
- More Flexible – qRules Plugin
- Most Scalable – DBXL Web Service: