Infopath with SharePoint 2016 gives 5566 error, The custom code in the form cannot be run.

This post has been republished via RSS; it originally appeared at: New blog articles in Microsoft Tech Community.

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,

clipboard_image_1.png

 

Create a new text field to hold the current logged in user and configure below form load rules,

1. field1 = substring-after(userName(), "|")

clipboard_image_2.png

2. AccountName = field1

clipboard_image_4.png

3.  Query GetUserProfileByName

clipboard_image_5.png

The above form load action in addition to existing rules should fix the issue.

REMEMBER: these articles are REPUBLISHED. Your best bet to get a reply is to follow the link at the top of the post to the ORIGINAL post! BUT you're more than welcome to start discussions here:

This site uses Akismet to reduce spam. Learn how your comment data is processed.