Infopath with SharePoint 2016 "GetUserProfileByName" fails with 5566 error, "The custom code in the form cannot be run. This functionality may be deactivated on the server. For more information, contact the server farm administrator. ---> System.NullReferenceException: Object reference not set to an instance of an object."
When using GetUserProfileByName in SharePoint 2016, we get the below error:
The custom code in the form cannot be run. This functionality may be deactivated on the server. For more information, contact the server farm administrator. ---> System.NullReferenceException: Object reference not set to an instance of an object.
Note: This behavior is only with SharePoint 2016 browser forms, preview(filler) works fine. Also the same form\rules works well in SP 2013 both in browser and filler.
Solution:
Make sure that GetUserProfileByName data connection has below option unchecked,
Create a new text field to hold the current logged in user and configure below form load rules,
1. field1 = substring-after(userName(), "|")
2. AccountName = field1
3. Query GetUserProfileByName
The above form load action in addition to existing rules should fix the issue.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.