"Object Reference not set to an instance of an object" Error in K2 Studio or K2 for Visual Studio

  • 24 February 2022
  • 0 replies
  • 326 views

Userlevel 5
Badge +20
 

"Object Reference not set to an instance of an object" error in K2 Studio or K2 for Visual Studio

kbt133606

PRODUCT
K2 blackpearl
BASED ON
K2 blackpearl 4.7
TAGS
K2 Designer for Visual Studio
K2 Studio
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.
LEGACY/ARCHIVED CONTENT
This article has been archived, and/or refers to legacy products, components or features. The content in this article is offered "as is" and will no longer be updated. Archived content is provided for reference purposes only. This content does not infer that the product, component or feature is supported, or that the product, component or feature will continue to function as described herein.

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 may also 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]);

--Select any Object that does not exist in category
SELECT * FROM [Category].[Data] WHERE [Data] not in (SELECT [SmartObjectGUID] FROM [SmartBroker].[SmartObject]) AND [DataType] = 'SmartObject'
UNION
SELECT * FROM [Category].[Data] WHERE [Data] not in (SELECT [ID] FROM [Form].[Form] UNION SELECT [ID] FROM [Form].[Form_Design]) AND [DataType] = 'Form'
UNION
SELECT * FROM [Category].[Data] WHERE [Data] not in (SELECT [ID] FROM [Form].[View] UNION SELECT [ID] FROM [Form].[View_Design]) AND [DataType] = 'View'

 

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. 

 

 

 


0 replies

Be the first to reply!

Reply