When you have an InfoPath form containing a data connection for retrieving SharePoint list data you might get these below error:
"You do not have permissions to access a SharePoint list that contains data required for this form to function correctly.".
This error might occur after redeployment of the form in for example SharePoint webtemplate solution (recreation of the site and list) or you try to deploy the form on an other site.
In this situation the problem isn't actually an access denied error. The real problem here is that for InfoPath services the list doesn't seems to exist.
The reason for this is that list you retrieve data from has gotten a new unique GUID. (Data Connection retrieves data from the list by looking for it's unique GUID.)
The advice here is that you use a SharePoint Data Connection library for storage of the UDCX files.
Deployment of the form by using a feature you now are able to dynamically update the UDCX file and change the List GUID (and to make other changes when needed).
<udc:ConnectionInfo Purpose="ReadOnly" AltDataSource="">
<udc:WsdlUrl/>
<udc:SelectCommand>
<udc:ListId>{7CB78DC5-5BDD-4C66-8C33-0375FFAAFBD1}</udc:ListId>
<udc:WebUrl>your site url</udc:WebUr>
ListId > Update it to the new unique GUID id of the list after recreation.
WebUrl > Update the Url also when needed.
In a OTAP situation i expect that connection of InfoPath form to the SharePoint Data Connection lib is relative. So no updates needed in the InfoPath form in OTAP situation deployment.
See these two Links for deployment of InfoPath forms by feature and dynamically updating your UDCX files:
http://nader.elshehabi.com/2011/08/how-to-really-deploy-infopath-2010-forms-with-code-behind-as-a-feature/
http://nader.elshehabi.com/2011/09/dynamically-modifying-udcx-connection-files/
Greetings,
Stefan Lankester