Infopath with SharePoint 2016 gives 5566 error, The custom code in the form cannot be run.
Published Dec 17 2019 10:32 PM 5,072 Views
Microsoft

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.

Version history
Last update:
‎Aug 27 2020 03:47 PM
Updated by: