Blog Post

Microsoft SharePoint Blog
1 MIN READ

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

Premkumarkc's avatar
Premkumarkc
Icon for Microsoft rankMicrosoft
Dec 17, 2019

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.

Updated Aug 27, 2020
Version 2.0
No CommentsBe the first to comment