Dynamic Module - Duplicate Entries - ContentLifecycleStatus.

Posted by Community Admin on 04-Aug-2018 14:08

Dynamic Module - Duplicate Entries - ContentLifecycleStatus.Live

All Replies

Posted by Community Admin on 28-Nov-2012 00:00

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

Posted by Community Admin on 28-Nov-2012 00:00

Have you tried

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

?

Posted by Community Admin on 28-Nov-2012 00:00

Hi Steve,

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

Thanks,
Stuart

Posted by Community Admin on 29-Nov-2012 00:00

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

Posted by Community Admin on 04-Jan-2017 00:00

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

any other suggestions?

 

This thread is closed