Saturday, September 20, 2008

Workflow Task Form Data Connections

Error

While I was working with a state workflow in SharePoint I ran into a problem with make secondary data connections my Task forms. I was getting the infamous "5566 An error occurred accessing a data source".

Background

Well Google was giving my tons of hits on the error but nothing helpful at all. I basically had a custom web service that I needed my Task form to use. Here was the situation:

  • I had a data connection a web service which I had converted and placed into a Connection Library in SharePoint.
  • Had changed the form properties to be Full Trust.
  • When I ran the preview of the InfoPath, the data connections were successful.
  • Here is where it gets interesting. I was able to deploy the form through central administration (because the form had full trust) and then associated the content type to a form library. When I opened the form as a web enabled form, it worked!

That last bullet completely confused me. Why would it work if I deployed the form manually but when the same InfoPath form was being used in a workflow it would not work?

Solution

After digging at it for a while this is what I found. Data connections that were executed through a rule would work however and data connections that were executed when the form was opened would not. For instance, I had a dropdown that I wanted to be loaded when the form was opened. So when I created the data connection on the last step of the wizard I set it to "Automatically retrieve data when the form is opened". My solution was to clear that checkbox and then go to Tools >> Form Options >> Open and Save >> and press the Rules button in the Open behavior section. I then added a Rule to query the data connection and then everything worked. Really strange…

No comments: