This article was created in response to a support issue logged with K2. The content may include typographical errors and may be revised at any time without notice This article is not considered official documentation for K2 software and is provided “as is” with no warranties.

Issue

When editing Form rules the following error appears: "Object Reference not set to an instance of an object"

Image

Symptoms

You are unable to edit any form rules on form level due to invalid event definitions.

Error:

"Object Reference not set to an instance of an object"

Troubleshooting Steps

Please note that the following steps are only applicable to K2 4.6.11 and older. The SQL Query is not compatible with K2 Five.

To determine if there are missing orphaned references, execute the script below:

--######################################################################

--### Instructions ###

-- 1. Check out only the forms that have the Object Reference error which you want to fix.

-- 2. Run the SQL script against the K2 database.

--######################################################################

Use [K2Database]

GO

declare @OrpanedReference int

select @OrpanedReference = count(*) from (

                select ID

               from [Form].[HandlerInstance_Design]

               where

                                 Functions.value('(/Function/@InstanceID)[1]', 'nvarchar(50)') is not null and

                                 Functions.value('(/Function/@InstanceID)[1]', 'nvarchar(50)') not in (SELECT [ID] FROM [Form].[AreaItem_Design])

                                 ) as a

if(@OrpanedReference>0)

begin

                     print 'There are ' + cast(@OrpanedReference as nvarchar(10)) + ' orphaned references found.'

end

else

                     print 'There were no orphaned references found.'

Under normal circumstances, no data should be displayed on any of the results.

Should the results display data, it means that orphaned references were found, which is the cause of the error.

Image

To resolve this issue, direct database modification will be required. Please log a K2 Support Ticket on the K2 Customer Portal for assistance in resolving the issue.

Please Note that direct K2 database modification is not allowed as it might leave the environment in an unsupported state. This must only be done with the assistance of, or when instructed to do so by K2 Support.