Filtering dynamic content items in the backend grid by workflow status

August 30, 2012 Digital Experience

Since the release of the module builder we've been asked number of times how to add filters to the dynamic items grid view. If you navigate to Content -> Dynamic Type in the sidebar there are only options to view "All" and "My" items which is not enough. Here I am going to show you how to enrich the sidebar in the content type page. For instance news can be filtered by their status – Draft, Unpublished and so on while dynamic items grid view doesn’t have these options. 

Fortunately workflow status filters can be easily added from Sitefinity Settings. To configure it navigate to Administration -> Advanced -> DynamicModules -> Telerik.Sitefinity.DynamicTypes.Model.CustomModule.CustomContentType -> Views -> CustomContentTypebackendList -> Sidebar -> Sections -> Filters -> Items. Create new CommandWidgetElement and set the following properties:

Command name: filter
Command argument: {filterExpression : "ApprovalWorkflowState = \"Draft\""}
Command button type: SimpleLinkButton
Name: DraftItems
CommandText: DraftItems
Type: Telerik.Sitefinity.Web.UI.Backend.Elements.Widgets.CommandWidget

Save and go to Content -> Dynamic Content Type. In the sidebar you can see the new filter and by clicking it the grid is updated only with draft items. To create and other workflow status filters just follow these steps and change the Command argument to:

Published items: {filterExpression : "ApprovalWorkflowState = \"Published\""}
Draft items: {filterExpression : "ApprovalWorkflowState = \"Draft\""}
Unpublished  items: {filterExpression : "ApprovalWorkflowState = \"Unpublished\""}
Scheduled for publishing items : {filterExpression : "ApprovalWorkflowState = \"Scheduled\""}

If you have one or two level workflow the following filters can be applied:

Awaiting approval items : {filterExpression : "ApprovalWorkflowState = \"AwaitingApproval\""}
Awaiting publishing items : {filterExpression : "ApprovalWorkflowState = \"AwaitingPublishing\""}

The Progress Team