Problem retrieving data collection in Module Builder

Posted by Community Admin on 05-Aug-2018 19:39

Problem retrieving data collection in Module Builder

All Replies

Posted by Community Admin on 08-Apr-2013 00:00

Hi,

I have created a custom module using Module Builder. I use the following code to return collection.

// Gets a collection of "live" and "visible" employee items.
protected IQueryable<DynamicContent> GetDataItems()
    DynamicModuleManager dynamicModuleManager = DynamicModuleManager.GetManager();
    Type employeeType = TypeResolutionService.ResolveType("Telerik.Sitefinity.DynamicTypes.Model.Employees.Employee");
  
    // Fetch a collection of "live" and "visible" employee items.
    var myCollection = dynamicModuleManager.GetDataItems(employeeType)
        .Where(i => i.Status == Telerik.Sitefinity.GenericContent.Model.ContentLifecycleStatus.Live && i.Visible == true);
  
    return myCollection;

For some reason, when I am logged in, the function returns six items in the collection, but when I am logged out, it returns 0 item in the collection (myColloection.Count() = 0, and dynamicModuleManager.GetDataItems(employeeType).Count = 0).

I want the function to return six items even I am not logged in. Please help.

Thanks,
Jimmy 



Posted by Community Admin on 08-Apr-2013 00:00

By default dynamic modules permissions are set to be only accessible to administrators.  Check your permissions for this module.

Also, you can suppress security checks.  Before you run your code to retrieve the items just set SuppressSecurityChecks to TRUE and then after you are done, set it back to FALSE.

dynamicModuleManager.Provider.SuppressSecurityChecks = true;

Also, here is another post that demonstrates this concept.

www.sitefinity.com/.../concurrent-cms-user-and-custom-control

Hopefully this will help.

Craig

This thread is closed