10-17-2017 05:30 AM
10-17-2017 08:00 AM
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
10-17-2017 08:00 AM
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
12-14-2020 11:44 PM
HI i am not getting the default webscript to override what is the location of the webscript ..
12-15-2020 08:05 AM
If this is related alfresco then it's wrong place.
Which webscript you want to override?
12-15-2020 11:41 PM
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?}&state={state?}&priority={priority?}&pooledTasks={pooledTasks?}&dueBefore={dueBefore?}&dueAfter={dueAfter?}&properties={properties?}&maxItems={maxItems?}&skipCount={skipCount?}&exclude={exclude?}&property={propQName/propValue?}</url>
<url>/api/workflow-instances/{workflow_instance_id}/task-instances?authority={authority?}&state={state?}&priority={priority?}&dueBefore={isoDate?}&dueAfter={isoDate?}&properties={prop1, prop2, prop3...?}&maxItems={maxItems?}&skipCount={skipCount?}&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.
12-17-2020 02:50 AM
Dear sir @abhinavmishra14 please help us in this .
10-02-2021 05:37 AM
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.
Explore our Alfresco products with the links below. Use labels to filter content by product module.