3 minute read
I’m building a reasonably complex form with InfoPath 2013 in which I need to look up data for some dropdowns from several external REST Web Services. The REST services are available publicly and anonymously, so authentication isn’t any issue.
For example, say I have a field on the form which displays values for Category in a dropdown. The form is housed on the domain https://mydomain.sharepoint.com at Office365 [in a subsite, but that shouldn’t matter] and the REST service which provides the available values for Category is housed on http://www.someotherdomain.com. The latter domain is fully in our control, but it’s non-Microsoft.
I needed to be able to open the form in the browser for the users, but when I tried to do so, I got an error like this:
An error occurred querying a data source.
Click OK to resume filling out the form. You may want to check your form data for errors.A query to retrieve form data cannot be completed because this action would violate cross-domain restrictions.
If this form template is published to a SharePoint document library, cross-domain access for user form templates must be enabled under InfoPath Forms Services in SharePoint Central Administration, and the data connection settings must be stored in a UDC file in a data connection library in the same site collection.
If this is an administrator-approved form template, the security level of the form must be set to full trust, or the data connection settings must be stored in a UDC file by using the Manage data connection files option under InfoPath Forms Services in SharePoint Central Administration.
An entry has been added to the Windows event log of the server.
I understand all about cross-browser scripting, but this is SharePoint, which always makes things more complicated. Since we don’t have access to Central Administration, what was the right solution? Everything here is fully trusted, and the REST services are read only. There had to be a way.
I posted this as a question on the MSDN Forums at SharePoint forums > SharePoint 2013 – Using SharePoint Designer, InfoPath and Other Customizations. There were some good suggestions, but I finally stumbled on what seems to be the best fix.
When you look at your existing data connections, you can choose a data connection and Convert to Connection File…. You must have a Data Connection library in your Site Collection in which to store the UDCX files.
So, the steps seem to be:
- Create a Data Connection Library in your Site Collection (I added it in the root of mine)
- In the InfoPath ribbon, go to Data, then Data Connections. Your existing data connections should be listed.
- Choose the data connection which is hosted on a different domain.
- Clink the Convert to Connection File… button
- In the location selector, specify the path to the Data Connection Library you created above. Mine is at https://tenantname.sharepoint.com/sites/Projects/DataConnections/ and append the name for the connection file, such as Categories.udcx
- Leave the Relative to site collection (recommended) radio button selected.
- Click OK
Once the operation completes, you’ll have a new item in your Data Connection Library, and the data connection should work in a browser-based form. In essence, what you’ve accomplished above is to tell SharePoint that the connection you would like to use is trusted.
All this without access to Central Administration!