Whilst working on client project recently that involved InfoPath within Office365 I immediately wanted to use a commonly employed technique with previous projects – using the GetUserProfileByName web-service to obtain the users first and last name.
There are a number benefits to doing this, especially when the project inevitably involves workflow, custom library views, webparts etc to have a personalized experience for the user. For this specific project we needed to get the user of the form within the document as they were to form official standalone documents (as in out of the SharePoint document library context).
Unfortunately there is a BIG limitation…
“This issue occurs because loopback protection is enabled in the SharePoint Online environment. Loopback protection must be disabled for InfoPath forms to be able to connect to a SharePoint Online web service.
Any time that you make a call to the same server from an InfoPath form, the requests to loop back. This works only when loopback protection is disabled. For security reasons, loopback protection is always enabled in SharePoint Online. This is a known limitation of InfoPath forms in the Office 365 SharePoint Online environment, and there is no workaround for this issue.
Here is the article for your reference: http://support.microsoft.com/kb/2674193“
So we need another way to get the user data from within Office 365 and into the InfoPath form and I devised the following solution:
The overview is as follows
- an InfoPath webpart
- a query string filter connected to the InfoPath webpart
Now I had to provision a page with the Infopath webpart and a few other connected webparts
I then needed to get the InfoPath form to react to a query string filter webpart
Passing Parameters to Infopath –
I used some of the script from Kit Menke’s blog here http://kitmenke.com/blog/2013/10/31/pass-user-information-from-sharepoint-2013-to-infopath-2013/
I simplified his script to just read the current user via “get_title()” and then pass this to the “window. location”
This redirects to a url with a query string parameter “CurrentUser” with this value
making sure to redirect only if the string “CurrentUser” is missing from the url. See the “check” statement…
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
So I now had the current user in the url and the query string filter webpart reading the value and passing this to the InfoPath form field – I then had a people picker field read this value and bingo I could interact as if the original query was there.
Hope this helps someone else.