Problem retrieving data collection in Module Builder - Front- & Back-End Development - Front- & Back-End Development - Progress Community
 Front- & Back-End Development

Problem retrieving data collection in Module Builder

  • Problem retrieving data collection in Module Builder
  • 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 



  • 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