More in this section

Forums / Bugs & Issues / Dynamic Module - Duplicate Entries - ContentLifecycleStatus.Live

Dynamic Module - Duplicate Entries - ContentLifecycleStatus.Live

5 posts, 0 answered
  1. Stuart
    Stuart avatar
    33 posts
    Registered:
    01 Nov 2012
    28 Nov 2012
    Link to this post
    Hi,

    I developed a custom module "Milestones" with data type "Milestones" and singular  type "Milestone". I'm then using an MVC widget to access the Milestones and display them in chronological order. 

    The code I use to read the items from the database:
    var dynamicModuleManager = DynamicModuleManager.GetManager();
    var milestoneType =       TypeResolutionService.ResolveType("Telerik.Sitefinity.DynamicTypes.Model.Milestones.Milestone");
    var milestones = dynamicModuleManager.GetDataItems(milestoneType).Where(c => c.Status == ContentLifecycleStatus.Live);
    var milestonesSorted = from milestone in milestones
                           orderby milestone.GetValue<decimal>("Year")
                           ascending
                           select milestone;

    I then loop through each item in milestonesSorted, create an object instance, and add it to a list. That list has two items for each entry in the Milestones module. When I display the status on output in the view, both copies of each record show "Live". 

    If I change the ContentLifecycleStatus.Live to ContentLifecycleStatus.Master, I still get duplicate records and the status on all shows "Master". 

    If I comment out the "Where" clause entirely, I get two copies of Live and two copies of Master that are output in the view. 

    In the Content>Milestones section of the Sitefinity backend, I see only the 6 separate items I created. In SQL Server Management studio for the dbo.milestone table, I see 12 entries, and for the dbo.milestone_sf_content_link, I also see 12 entries. 

    I understand that there should be twice as many rows in the table as there are in viewable in the backend because one is stored as Master and one as Live; However, I don't understand why I seem to output twice again that many with duplicates of both Master and Live.

    I have tried unpublishing individual items, which makes no change in their visibility. Deleting items removes them, but once they're re-added, the duplicate problem is unchanged. 

    Thanks,
    Stuart

  2. Steve
    Steve avatar
    3037 posts
    Registered:
    03 Dec 2008
    28 Nov 2012
    Link to this post
    Have you tried

    c.Status == ContentLifecycleStatus.Live && c.Visible == true

    ?
  3. Stuart
    Stuart avatar
    33 posts
    Registered:
    01 Nov 2012
    28 Nov 2012 in reply to Steve
    Link to this post
    Hi Steve,

    I added that condition into the where clause and it had no effect on the result. 

    Thanks,
    Stuart
  4. Stuart
    Stuart avatar
    33 posts
    Registered:
    01 Nov 2012
    29 Nov 2012 in reply to Stuart
    Link to this post
    Hello,

    So I decided to delete the Module and try again. I recreated it and that seemed to take care of the problem. Perhaps there was some issue with my database or something... Anyway, it's fixed now.

    Thanks,
    Stuart
  5. Ketan
    Ketan avatar
    0 posts
    Registered:
    15 Jul 2016
    04 Jan
    Link to this post

    @Stuart i am facing the same issue but recreation it is not fixing my issue??

    any other suggestions?

     

5 posts, 0 answered