Custom Module Problems
I created a custom Module called Classes (Class) through Module Builder. Populated the content with a script and drag and dropped the default Class Widget into a page for testing. The list populates just fine but when I click on any of the classes to view the detail view of the individual class content I get an error:
Server Error in '/' Application.
No row for Telerik.Sitefinity.DynamicModules.Model.DynamicContent ('sf_dynamic_content') GenericOID@dff2a5b DynamicContent base_id=1e481f8e-58d4-6fca-ad84-ff0000f16163 NOTRES
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: Telerik.OpenAccess.Exceptions.NoSuchObjectException: No row for Telerik.Sitefinity.DynamicModules.Model.DynamicContent ('sf_dynamic_content') GenericOID@dff2a5b DynamicContent base_id=1e481f8e-58d4-6fca-ad84-ff0000f16163 NOTRES
Source Error:
An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.
Stack Trace:
[NoSuchObjectException: No row for Telerik.Sitefinity.DynamicModules.Model.DynamicContent ('sf_dynamic_content') GenericOID@dff2a5b DynamicContent base_id=1e481f8e-58d4-6fca-ad84-ff0000f16163 NOTRES ]
DynamicModule.ns.Wrapped_OpenAccessDynamicModuleProvider_f6fb33f837434816b9b46e6003966a85.GetItemFromUrl(Type itemType, String url, Boolean published, String& redirectUrl) +357
Telerik.Sitefinity.DynamicModules.Web.UI.Frontend.DynamicContentView.IsSingleItem() +1855
Telerik.Sitefinity.DynamicModules.Web.UI.Frontend.DynamicContentView.CreateChildControls() +241
System.Web.UI.Control.EnsureChildControls() +83
Telerik.Sitefinity.DynamicModules.Web.UI.Frontend.DynamicContentView.OnInit(EventArgs e) +47
System.Web.UI.Control.InitRecursive(Control namingContainer) +134
System.Web.UI.Control.InitRecursive(Control namingContainer) +290
System.Web.UI.Control.InitRecursive(Control namingContainer) +290
System.Web.UI.Control.InitRecursive(Control namingContainer) +290
System.Web.UI.Control.InitRecursive(Control namingContainer) +290
System.Web.UI.Control.InitRecursive(Control namingContainer) +290
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +489
Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.0.30319.18446
I use the following code to populate the classes. Is there something wrong in here?
public
DynamicContent RetrieveClassThroughFiltering(DynamicModuleManager dynamicModuleManager,
string
eventID)
Type classType = TypeResolutionService.ResolveType(
"Telerik.Sitefinity.DynamicTypes.Model.Classes.Class"
);
// This is how we get the class items through filtering
var myFilteredCollection = dynamicModuleManager.GetDataItems(classType).Where(
"wvc_event_id = \""
+eventID+
"\""
);
if
(myFilteredCollection.Count()>0)
return
myFilteredCollection.First();
else
return
null
;
public
bool
CreateOrUpdateClass(JObject theClass)
// Set the provider name for the DynamicModuleManager here. All available providers are listed in
// Administration -> Settings -> Advanced -> DynamicModules -> Providers
var providerName =
"OpenAccessProvider"
;
DynamicModuleManager dynamicModuleManager = DynamicModuleManager.GetManager(providerName);
Type classType = TypeResolutionService.ResolveType(
"Telerik.Sitefinity.DynamicTypes.Model.Classes.Class"
);
DynamicContent classItem = RetrieveClassThroughFiltering(dynamicModuleManager, theClass[
"EventID"
].ToString());
bool
newFlag =
false
;
if
(classItem==
null
)
newFlag =
true
;
classItem = dynamicModuleManager.CreateDataItem(classType);
else
classItem = dynamicModuleManager.Lifecycle.CheckOut(classItem)
as
DynamicContent;
// This is how values for the properties are set
classItem.SetValue(
"Instructors"
, theClass[
"instructors"
].ToString());
classItem.SetValue(
"Sponsors"
, theClass[
"sponsors"
].ToString());
classItem.SetValue(
"Title"
, theClass[
"EventTitle"
].ToString());
classItem.SetValue(
"Description"
, theClass[
"description"
].ToString());
classItem.SetValue(
"wvc_event_hotel_description"
, theClass[
"hotel_description"
].ToString());
classItem.SetValue(
"wvc_event_id"
, theClass[
"EventID"
].ToString());
classItem.SetValue(
"wvc_event_category"
, theClass[
"EventCategory"
].ToString());
classItem.SetValue(
"wvc_event_class"
, theClass[
"EventClass"
].ToString());
classItem.SetValue(
"wvc_event_search"
, theClass[
"EventSearch"
].ToString());
classItem.SetValue(
"wvc_event_rank"
, theClass[
"EventRank"
].ToString());
classItem.SetValue(
"wvc_event_status"
, theClass[
"EventStatus"
].ToString());
classItem.SetValue(
"wvc_event_type"
, theClass[
"EventType"
].ToString());
classItem.SetValue(
"wvc_event_audience"
, theClass[
"details"
][
"Audience"
].ToString());
classItem.SetValue(
"wvc_event_available"
, theClass[
"details"
][
"Available"
].ToString());
classItem.SetValue(
"wvc_event_capacity_max"
, theClass[
"details"
][
"MaxCapacity"
].ToString());
classItem.SetValue(
"wvc_event_capacity_session"
, theClass[
"details"
][
"SessionCapacity"
].ToString());
classItem.SetValue(
"wvc_event_cehours"
, theClass[
"details"
][
"CEHours"
].ToString());
classItem.SetValue(
"wvc_event_featured"
, theClass[
"details"
][
"Featured"
].ToString());
classItem.SetValue(
"wvc_event_func_id"
, theClass[
"details"
][
"FuncID"
].ToString());
classItem.SetValue(
"wvc_event_number"
, theClass[
"details"
][
"SessionNumber"
].ToString());
classItem.SetValue(
"wvc_event_objectives"
, theClass[
"details"
][
"CourseObjectives"
].ToString());
classItem.SetValue(
"wvc_event_outline_url"
, theClass[
"details"
][
"CourseOutlineURL"
].ToString());
classItem.SetValue(
"wvc_event_program_area"
, theClass[
"details"
][
"ProgramArea"
].ToString());
classItem.SetValue(
"wvc_event_program_category"
, theClass[
"details"
][
"ProgramCategory"
].ToString());
classItem.SetValue(
"wvc_event_program_type"
, theClass[
"details"
][
"ProgramType"
].ToString());
classItem.SetValue(
"wvc_event_raceapproved"
, theClass[
"details"
][
"RACEApproved"
].ToString());
classItem.SetValue(
"wvc_event_registration_url"
, theClass[
"details"
][
"CourseRegistrationURL"
].ToString());
classItem.SetValue(
"wvc_event_sold"
, theClass[
"details"
][
"CurrentSold"
].ToString());
classItem.SetValue(
"wvc_event_usage"
, theClass[
"details"
][
"Usage"
].ToString());
classItem.SetValue(
"wvc_event_wvcondemand"
, theClass[
"details"
][
"WVCOnDemand"
].ToString());
classItem.SetValue(
"wvc_event_wvctv"
, theClass[
"details"
][
"WVCTV"
].ToString());
classItem.SetValue(
"wvc_event_start_date"
, theClass[
"StartDate"
].ToString());
classItem.SetValue(
"wvc_event_end_date"
, theClass[
"EndDate"
].ToString());
classItem.SetValue(
"wvc_event_start_timestamp"
, DateTime.Parse(theClass[
"details"
][
"FunctionStartTime"
].ToString()));
classItem.SetValue(
"wvc_event_end_timestamp"
, DateTime.Parse(theClass[
"details"
][
"FunctionEndTime"
].ToString()));
classItem.SetString(
"UrlName"
, Regex.Replace(theClass[
"EventTitle"
].ToString().ToLower(), @
"[^\w\-\!\$\'\(\)\=\@\d_]+"
,
"-"
));
classItem.SetValue(
"Owner"
, SecurityManager.GetCurrentUserId());
classItem.SetValue(
"PublicationDate"
, DateTime.Now);
if
(newFlag)
classItem.SetWorkflowStatus(dynamicModuleManager.Provider.ApplicationName,
"Draft"
);
dynamicModuleManager.Provider.SuppressSecurityChecks =
true
;
// You need to call SaveChanges() in order for the items to be actually persisted to data store
dynamicModuleManager.SaveChanges();
dynamicModuleManager.Provider.SuppressSecurityChecks =
false
;
// We can now call the following to publish the item
ILifecycleDataItem publishedClassItem = dynamicModuleManager.Lifecycle.Publish(classItem);
//You need to set appropriate workflow status
classItem.SetWorkflowStatus(dynamicModuleManager.Provider.ApplicationName,
"Published"
);
dynamicModuleManager.Provider.SuppressSecurityChecks =
true
;
// You need to call SaveChanges() in order for the items to be actually persisted to data store
dynamicModuleManager.SaveChanges();
dynamicModuleManager.Provider.SuppressSecurityChecks =
false
;
else
ILifecycleDataItem checkInClassItem = dynamicModuleManager.Lifecycle.CheckIn(classItem);
dynamicModuleManager.Lifecycle.Publish(checkInClassItem);
dynamicModuleManager.Provider.SuppressSecurityChecks =
true
;
// You need to call SaveChanges() in order for the items to be actually persisted to data store
dynamicModuleManager.SaveChanges();
dynamicModuleManager.Provider.SuppressSecurityChecks =
false
;
return
newFlag;
Hello Piotr,
I have responded in your support ticket, once we manage to determine the reason for this issue I will appreciate if you share the solution with the community.
Kind regards,
Vassil Vassilev
Telerik
Hi
Please share solution we got the same issue with dynamic content.
Thansk
Hello Artem,
Similar issues are best resolved trough debugging and most likely this is caused by setting some of your custom fields. I could advise as a best approach to comment all rows containing classItem.SetValue(...) and if no error appear, just start uncommenting code until you receive the error.
In this particular case, the issue was caused by classItem.SetValue("PublicationDate", DateTime.Now); and the most likely reason for this was a wrong field type.
Hope this helps.
Regards,
Vassil Vassilev
Telerik