Feedback
Did this article resolve your question/issue?

   

Article

Item type not specified error when working with DynamicContent API

« Go Back

Information

 
TitleItem type not specified error when working with DynamicContent API
URL NameItem-type-not-specified-error-when-working-with-DynamicContent-API
Article Number000179075
EnvironmentProduct: Sitefinity
Version: 13.x
OS: All supported OS versions
Database: All supported Microsoft SQL Server versions
Question/Problem Description
An error "Item type not correctly specified. Use the item's actual type. DynamicContent and null values are not supported." is thrown when working with DynamicContent API.
The error can occur in the following scenarios:
  1. Passing typeof(DynamicContent) as the type parameter on the GetDataItems or GetDataItem methods of the DynamicModuleManager class.
  2. Inheriting the OpenAccessDynamicModuleProvider class and overriding the GetDataItems, GetDataItem, GetItemOrDefault or GetCount methods.
  3. Importing a dynamic module that was exported from a Sitefinity application on version 9.0 or lower. In this case the error manifests in two places:
    1. When going to edit the permissions for this type under Actions -> Permissions
    2. When trying to edit the content of a dynamic content item displayed with a WebForms widget on a page using in-line editing
Steps to ReproduceCall the DynamicContent API with DynamicContent type.

DynamicContent testItem = DynamicModuleManager.GetManager().GetDataItems(typeof(DynamicContent)).FirstOrDefault();
Clarifying Information
Error MessageItem type not correctly specified. Use the item's actual type. DynamicContent and null values are not supported.
Defect/Enhancement Number
Cause
This is the expected behavior. Using the API with no type or a base type causes severe performance degradation. Refer to following KnowledgeBase articles for example issues:
-  Huge database queries when unlocking a dynamic content item in the backend 
-  Unable to request a page with dynamic content due to a timeout
-  Unable to create dynamic content items due to a timeout
Resolution

Issue 1:

Pass the correct, fully-qualified type of the specific module. Dynamic module types are constructed in the format Telerik.Sitefinity.DynamicTypes.Model.<DynamicModuleName>.<DynamicTypeName>
Example:
Type countryType = TypeResolutionService.ResolveType("Telerik.Sitefinity.DynamicTypes.Model.TravellingAgency.Country");
DynamicContent country = dynamicModuleManager.GetDataItems(countryType).FirstOrDefault();

Issue 2:

Add the following code to the beginning of the overridden methods to prevent the execution of problematic queries:
if (itemType == null || itemType == typeof(DynamicContent))
    throw new ArgumentException("Item type not correctly specified. Use the item's actual type. DynamicContent and null values are not supported.");

Issue 3.a:

1. Navigate to Administartion -> Settings -> Advanced -> DynamicModules -> Controls -> Telerik.Sitefinity.DynamicTypes.Model.<DynamicModuleName>.<DynamicTypeName>Definition -> Views -> <DynamicModuleName>BackendList -> Dialogs -> ModulePermissionsDialog on permissionsDynamicContent -> Parameters
2. Change
Telerik.Sitefinity.DynamicModules.Model.DynamicContent to Telerik.Sitefinity.DynamicTypes.Model.<DynamicModuleName>.<DynamicTypeName>Definition

Issue 3.b:

Replace the WebForms widget with an MVC widget.
Workaround
Notes
Last Modified Date11/20/2020 6:53 AM
Attachment 
Files
Disclaimer The origins of the information on this site may be internal or external to Progress Software Corporation (“Progress”). Progress Software Corporation makes all reasonable efforts to verify this information. However, the information provided is for your information only. Progress Software Corporation makes no explicit or implied claims to the validity of this information.

Any sample code provided on this site is not supported under any Progress support program or service. The sample code is provided on an "AS IS" basis. Progress makes no warranties, express or implied, and disclaims all implied warranties including, without limitation, the implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample code is borne by the user. In no event shall Progress, its employees, or anyone else involved in the creation, production, or delivery of the code be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample code, even if Progress has been advised of the possibility of such damages.