sitecoresitecore6sitecore-workflow

Sitecore workbox only display the latest Version of an item


I have customized workbox by overriding it. By default Workbox displays all versions of items in a particular workflow state. I need only the last version to appear in the workbox. Played around with the DisplayStates(IWorkflow workflow, XmlControl placeholder) method, but no luck.

How can I do this?


Solution

  • You need to override DisplayStates() method and filter the DataUri[] items array:

    List<DataUri> filteredUriList = new List<DataUri>();
    DataUri[] items = this.GetItems(state, workflow);
    
    for (int index = offset; index < num; ++index)
    {
        Item obj = Sitecore.Context.ContentDatabase.Items[items[index]];
        if (obj != null && obj.Versions.IsLatestVersion())
            filteredUriList.Add(items[index]);
    }
    items = filteredUriList.ToArray();