Latest task instances

cancel
Showing results for 
Search instead for 
Did you mean: 
owerfelli
Active Member

Latest task instances

Jump to solution

I'm in ,

I want to know if there is a webscript that return task instances sorted by date or the x latest instances 

1 Solution

Accepted Solutions
kalpesh_c2
Senior Member

Re: Latest task instances

Jump to solution

Hi Oussama Werfelli

The existing webscript provided by alfresco which gives the list of tasks, sorts tasks by due date  in ascending order. In order to get latest task first you can override webscript and sort the task list.

Thanks

Kalpesh

ContCentric

View solution in original post

6 Replies
kalpesh_c2
Senior Member

Re: Latest task instances

Jump to solution

Hi Oussama Werfelli

The existing webscript provided by alfresco which gives the list of tasks, sorts tasks by due date  in ascending order. In order to get latest task first you can override webscript and sort the task list.

Thanks

Kalpesh

ContCentric

View solution in original post

akash251998
Established Member II

Re: Latest task instances

Jump to solution

HI i am not getting the default webscript to override what is the location of the webscript .. 

 

sanjaybandhniya
Intermediate

Re: Latest task instances

Jump to solution

If this is related alfresco then it's wrong place.

Which webscript you want to override?

Thanks & Regards,
Sanjay
akash251998
Established Member II

Re: Latest task instances

Jump to solution

I am overriding TaskInstancesGet.java .

1--> I have pasted TaskInstancesGet.java file at the location tomcat\webapps\alfresco\WEB-INF\classes\org\alfresco\repo\web.

And changed  WorkflowModel.PROP_DUE_DATE to ContentModel.PROP_CREATED in TaskInstancesGet.java.

 

2--> And have registered bean in the file custom-webscripts -context.xml at location tomcat\shared\classes\alfresco\extension:-

<bean id="webscript.org.alfresco.repository.workflow.task-instances.get"

            class="org.alfresco.repo.web.scripts.workflow.TaskInstancesGet"

           parent="abstractWorkflowWebScript"

</bean>

3--> And pasted a file named task-instances.get.desc.xml at location  tomcat\shared\classes\alfresco\extension\templates\webscripts\org\alfresco\repository\workflow

with content:-

<webscript>
<shortname>List workflow tasks</shortname>
<description>
Lists all Workflow Task Instances associated with an authority and of a given State.
The list of returned tasks also includes pooled tasks which the specified authority is eligible to claim.
</description>
<url>/api/task-instances?authority={authority?}&amp;state={state?}&amp;priority={priority?}&amp;pooledTasks={pooledTasks?}&amp;dueBefore={dueBefore?}&amp;dueAfter={dueAfter?}&amp;properties={properties?}&amp;maxItems={maxItems?}&amp;skipCount={skipCount?}&amp;exclude={exclude?}&amp;property={propQName/propValue?}</url>
<url>/api/workflow-instances/{workflow_instance_id}/task-instances?authority={authority?}&amp;state={state?}&amp;priority={priority?}&amp;dueBefore={isoDate?}&amp;dueAfter={isoDate?}&amp;properties={prop1, prop2, prop3...?}&amp;maxItems={maxItems?}&amp;skipCount={skipCount?}&amp;exclude={exclude?}</url>
<format default="json"/>
<authentication>user</authentication>
<transaction allow="readonly">required</transaction>
<lifecycle>limited_support</lifecycle>
<args>
<arg>
<shortname>authority</shortname>
<description>The username of the authority to retrieve the tasks for. If this argument is omitted the tasks for the current user are returned.</description>
</arg>
<arg>
<shortname>state</shortname>
<description>Filters the returned tasks by state, IN_PROGRESS or COMPLETED (lower case is also acceptable). If this argument is omitted tasks in progress are returned.</description>
</arg>
<arg>
<shortname>priority</shortname>
<description>Filters the returned tasks by priority, a numerical value is expected, either 1, 2 or 3.</description>
</arg>
<arg>
<shortname>pooledTasks</shortname>
<description>Determines whether pooled tasks for the user are included in the results. To omit pooled tasks set this argument to false.</description>
</arg>
<arg>
<shortname>dueBefore</shortname>
<description>Restricts the returned tasks to only those that are due before the provided date (the date must be in ISO8601 format)</description>
</arg>
<arg>
<shortname>dueAfter</shortname>
<description>Restricts the returned tasks to only those that are due after the provided date (the date must be in ISO8601 format)</description>
</arg>
<arg>
<shortname>properties</shortname>
<description>Comma separated list of property names to include in the results. If this argument is omitted all properties are returned.</description>
</arg>
<arg>
<shortname>maxItems</shortname>
<description>Specifies the maximum number of results to return.</description>
</arg>
<arg>
<shortname>skipCount</shortname>
<description>Specifies the position in the results to start, used for paging results.</description>
</arg>
<arg>
<shortname>exclude</shortname>
<description>Comma separated list of task types to exclude from the the results.</description>
</arg>
<arg>
<shortname>workflow_instance_id</shortname>
<description>Restricts the returned tasks to those that belong to the given workflow process instance id.</description>
</arg>
<arg>
<shortname>property</shortname>
<description>Restricts the returned tasks to only those that match the given property. The property name should be a valid QName format followed by '/' then the property value. E.g. bpm:description/myDescription</description>
</arg>
</args>
<responses>
<response>
<format>json</format>
<type>
<![CDATA[
{
"data":
[
{
"id": string,
"url": string,
"name": string,
"title": string,
"description": string,
"state": string (IN_PROGRESS|COMPLETE),
"path": string,
"isPooled": boolean,
"isEditable": boolean,
"isReassignable": boolean,
"isClaimable": boolean,
"isReleasable": boolean,
"outcome": string,
"owner":
{
"userName": string,
"firstName": string,
"lastName": string
},
"properties":
{
"key": string, boolean, number, array or map,
...
},
"workflowInstance":
{
"id": string,
"url": string,
"name": string,
"title": string,
"description": string,
"isActive": boolean,
"startDate": string,
"priority": number,
"message": string,
"endDate": string,
"dueDate": string,
"context": string,
"package": string,
"initiator":
{
"userName": string,
"firstName": string,
"lastName": string
},
"definitionUrl": string
}
},
...
],
"paging":
{
"totalItems": number,
"maxItems": number,
"skipCount": number
}
}
]]>
</type>
</response>
</responses>

</webscript>

But it is not sorting there is no change on my task. I think instead of java file i need .class file

 

Now can you please tell me that i am following the correct procedure or not.

akash251998
Established Member II

Re: Latest task instances

Jump to solution

Dear sir @abhinavmishra14 please help us in this .

upforsin
Senior Member

Re: Latest task instances

Jump to solution

Hi @akash251998 

In your own package (i.e. com.example.workflow) you should create a TaskInstancesGet file (copied from the original file and with changed OrderBy and Comparator). Then in the custom-web-context.xml you should add a new bean with the same id as the original and changed package, i.e.:

<bean id="webscript.org.alfresco.repository.workflow.task-instances.get"
class="com.example.workflow.TaskInstancesGet"
parent="abstractWorkflowWebScript">
</bean>

That's it.

Final tip, instead of ContentModel.PROP_CREATED use WorkflowModel.PROP_START_DATE.