Monday, April 23, 2012

InfoPath Tips #6-RESTful web services as data source

Often we face the default Form Services Response Size cap at 1500k, if we cannot change it for some reason. We need to fetch the data chunk by chunk, and one option implementing this would be using RESTful. Steps:

Step 1: Add a REST Web Service for Data Retrieve

Step 2: Add an action for changing REST service URL

Step 3: Bind the service to the Control

Step 4: Bind Value and Display Name

Step 5: Mission Accomplished
 


Note, when the form was opened inside web browser there seemed to be issue accessing the RESTful service, the situation might be able mitigated if the form could be signed with digital certificate and given full trust.

Friday, April 6, 2012

InfoPath Tips #5-Concatenating Repeating Fields, the other scenario

This is going be a summary of the thread I posted on the InfoPathDev site.

A lot of people have read this or similar article about concatenating a field that stored in a repeating group, that is one scenario of a repeating field, the other scenario is to have a repeating field inside a none repeating group.I experimented many formula with the eval() function, and the closest result had two issues:
1) the result had a leading delimiter, and a trailing delimiter too
2) when you remove a selection from the multiple-selection list, the textbox control storing the concatenated value will not be updated.

The reason behind the first issue was the XML content of the InfoPath form actually has a blank first entry.

Finally I found the reply Jimmy Rishe posted on this thread. His formula basically filtered out the blank entry, generating a ";XYZ;XYZ;XYZ;" string then removed the first character using substring:

substring(eval(eval(field1[. != ""], 'concat(";", .)'), ".."), 2)


What I still not sure is what Jimmy did to get around the second issue. He added a formula to set the default value of the control which bound to the field that accepts the concatenated string-considering the prior action already was assigning a value to the field and the textbox was bound the field etc.
Oh, well, as long as it works. We should just move on.

InfoPath Tips #4-Performance Issue Related to Default Value with Formula

A month ago, a InfoPath Form we worked on was on its way to UAT, and the performance was that not satisfying, and one small trick improved the load time of the form from 30 seconds or more to close to 6 seconds, a 80% plus improvement.

We have quite some logic in our form, so one control/field's value would be depend upon the field value of another field, and we used a formula to set the Default Value of the first value with a field from a secondary data connections filtered by the value of the second field. Instead of doing this, I added action to the second field, whenever its values changes, InfoPath would use a similar formula to set the value of the first field.The key is we don't want to waste our CPU cycles re-calculating default values when the form is being loaded and only do the calculation when we need to.

So besides going over the performance guidelines Microsoft published, also pay a bit attention how you use the formula in default values.

InfoPath Tips #3-Promoting InfoPath fields properly and remove the Orphan Fields

In the age when every one is eating at fast food joints and addicted to the iPod, Microsoft provided us with a Quick Publish with InfoPath, it is easy to use but quite dangerous, you might end up with Orphan/Duplicate column in your Form library. My suggestion is almost use Publish Wizard and always match you fields to the site columns one by one *especially if* you are publishing a Form to a new SharePoint Server.

Orphan, it means the column of the form library doesn't belong to any content type; Duplicate means you could have one column belongs to a content type and another column with same *name* in the same library, the later often is an orphan.

To remove the Orphan column is a very painful process, and often you cannot do it using the SharePoint UI and have to use code.

I was planning to publish a utility I wrote just for this and put it on CodeProject, but CodeProject rejected it demanding a lot of formatting changes but I had no time for that, and on second thought as deleting a site column is a dangerous action to perform I decided not to release my code as a utility. As this issue is such a common one, other folks had written about their method of site column cleaning up as well, one that requires some of your own coding is this one:

http://nikspatel.wordpress.com/2010/08/07/delete-orphaned-workflow-status-columns-from-sharepoint-list-views/

(the idea behind my utility was after you selected a site list, the columns of this list that does NOT belong to ANY content type will be shown in a data grid this includes out of the box list columns and orphan columns from infopath or workflow, from there you could delete them one by one.)

InfoPath Tips #2-Moving Fields around when Designing Schema

If you are new to InfoPath, you would notice you cannot drag and drop fields and group when designing the schema-you should always create fields and groups on the right side schema pane instead just drag a control into the form which is another tip.

The trick is you hit F6 key to turn the Field/Group you wanted to move into orange color, then press down Ctrl key and the Arrow keys to move the element around the schema tree.

InfoPath Tips #1-Clearing the cache

I ran into an issue with InfoPath a couple months ago, struggled for like two days, almost reformatted my workstation because of it, it turned out to be an issue with InfoPath not *completely" clear.

"A parameter in the URL specifies to open the form in Microsoft InfoPath 2010. This product is not currently installed."

From the above error message itself, sounds like an InfoPath installation issue(reinstalling Office 2010 just didn't help), but after digging the log file on the server, it pointed me toward the InfoPath cache.

It turned out the following command doesn't get the clearing job done *completely*
infopath /cache clearall

I finally I ran into this article:

http://maspoint.wordpress.com/2011/03/01/infopath-designer-2010-cache-issue/

You *not only* need to do the above but also need to go to:
Start->Run->%LOCALAPPDATA%\Microsoft\InfoPath

And clean up there.



After I did this my problem went away.

hopefully this could help some one who ran into same issue.