I was developing a heavy InfoPath application with custom codes. The form contains around 40 data connection including external data connections, web services, etc… This form is using ‘Get User Profile By Name’ data connection which come along with the UserProfileService.asmx web services. The user profile web service url comes as follows: http://shpapp:2000/sites/Test/_vti_bin/UserProfileService.asmx
When I try to open the form in the preview mode it pops up below error message:
The query cannot be run for the following DataObject: Get User Profile By Name
InfoPath cannot run the specified query.
The SOAP response indicates that an error occurred: A user with the account name MohamedAkb could not be found. ---> An error was encountered while retrieving the user profile.
I started search, almost all the suggestions say set the form in to full trust mode as bellow:
- Go to File - > Form Options -> Security and Trust
- Select Full Trust option button.
The above option is use full to deploy the form at the farm level. If the form contains VSTA code, it is must to deploy as full trust mode. This doesn’t help to resolve the user profile issue.
To resolve the user profile issue follow below steps:
- At the create data connection wizard untick the ‘Automatically retrieve data when form is opened’ option.
- At the form load event create a rule to query the data connection. In the rule, set the query field as Account name = DOMAIN\UserName then query the data connection.
- Save the form and open in the preview mode. You will see no errors now.