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 using K2 Studio or K2 for Visual Studio and expanding the SmartObject Server(s) > SmartObject Server from the Object Browser, an "Object Reference not set to an instance of an object" error is displayed and no SmartObjects are visible in any of the Categories.

Symptoms

The following error message will be displayed:

Image

Troubleshooting Steps

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

Execute the following SQL query against the K2 Database:

Use K2 --Change to your K2 Database Name

 

DECLARE @result1 TABLE (ID INT, CategoryName nvarchar(100), MissingParentID INT)

 

insert into @result1

 

--Select all Categories with missing ParentID

select id, name,

r.value('@id','int')

FROM [Category].[Category]

CROSS APPLY [ParentCategories].nodes('/parentcategory[1]') AS x(r)

where r.value('@id','int') not in (select ID from [Category].[Category]);

 

select * from @result1;

 

--Select any Object currently in the Orphaned Category

select * from [Category].[Data]

where CategoryId in (select ID from @result1);

 

--Select any Object in category that does not exist

select * from [Category].[Data]

where CategoryId not in (select id FROM [Category].[Category]);

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

 

Should the results display data, it would indicate orphaned Categories and/or K2 Objects, which is the cause of the error.

 

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.