I want to sort my-task in alfresco share

cancel
Showing results for 
Search instead for 
Did you mean: 
Member II

I want to sort my-task in alfresco share

Hi,

I want to sort the visible task in my-task in descending order of the workflow initiated(I want workflow initiated to be on the top).

Please suggest.Thanks.

Below is the my-task screenshot

my-task.JPG

3 Replies
Senior Member II

Re: I want to sort my-task in alfresco share

Hi,

You need to check with the api(webscript) which is returning result.

Thanks & Regards,
Sanjay
Member II

Re: I want to sort my-task in alfresco share

sanjaybandhniya,

Could you show me how to do this?

Senior Member II

Re: I want to sort my-task in alfresco share

You need to override TaskInstancesGet webscript.(TaskInstancesGet.java)
In that file there is a Comparator which is sorting task by DueDate.
Here you need to change it to as per your scenario.
Ex.if you want latest created workflow comes first then you need to use ContentModel.PROP_CREATED instead of WorkflowModel.PROP_DUE_DATE.

Below Example willr display task by latest.

 class WorkflowTaskDueAscComparator implements Comparator<WorkflowTask>
    {
        @Override
        public int compare(WorkflowTask o1, WorkflowTask o2)
        {

        	Date date1 = (Date)o1.getProperties().get(ContentModel.PROP_CREATED);
            Date date2 = (Date)o2.getProperties().get(ContentModel.PROP_CREATED);
            
            long time1 = date1 == null ? Long.MAX_VALUE : date1.getTime();
            long time2 = date2 == null ? Long.MAX_VALUE : date2.getTime();
            
            
           return time1>time2?-1:1;
        }
        
    }
Thanks & Regards,
Sanjay