cancel
Showing results for 
Search instead for 
Did you mean: 

orderByProcessInstanceId()

emiliano
Champ in-the-making
Champ in-the-making
Hi,
I would like to retrieve the list of Tasks owned by a particular user ordered by their processInstanceId, so i have used:


taskService.createTaskQuery().taskAssignee(userId).orderByProcessInstanceId().asc()

Unfortunately I found that the order isn't respected, the task with the processInstanceId 152 was before the task with the piid 85.
I've searched why and i've found that the sql ORDER BY directive works on a varchar column. This drives to an alphanumeric ordering instead of numerical. So ids which start with '1' (es 1000) are positioned before ids which start with '2' (es 20).
Also orderByExecutionId() and orderByTaskId() seems to suffer the same problem.
Does anyone have experience the same problem?
Does exits a workaround?

thanks in advance
emiliano
5 REPLIES 5

frederikherema1
Star Contributor
Star Contributor
That's indeed a consequence of using ID's of type String. I'm afraid there is no workaround for this, other than sorting manually. However, the ID is an arbitrary number and by coincidence, the numbers increment trough time. When using the UUID-approach, these ID's don't increment the same way.

What is the exact need for you to order it by process-instance ID? Process-start Timing?

emiliano
Champ in-the-making
Champ in-the-making
What is the exact need for you to order it by process-instance ID? Process-start Timing?

Yes, I'm customizing the explorer to have inbox tasks ordered by start time of their process.
If i sort them manually the pagination of tasks will be wrong.
Are there any tricks to start the ids of execution from 1000000 instead of 1 ? This should workaround the problem for 9000000 ids Smiley Happy

thanks
emiliano

frederikherema1
Star Contributor
Star Contributor
You can alter the value of "next.dbid" in ACT_GE_PROPERTY after the engine is initialized and shut down. The next time the engine boots, the ID's will start from there…

Can't you use the task-create-time?

emiliano
Champ in-the-making
Champ in-the-making
You can alter the value of "next.dbid" in ACT_GE_PROPERTY after the engine is initialized and shut down. The next time the engine boots, the ID's will start from there…

Excellent, thanks a lot, i'll try it.

Can't you use the task-create-time?

My Customer wants the list of tasks sorted by process creation time, so I've to respect its wishes.

best regards
emiliano

jbarrez
Star Contributor
Star Contributor
My Customer wants the list of tasks sorted by process creation time, so I've to respect its wishes.

Then use the historyService to fetch the HistoricProcessInstance of your ProcessInstance. That one has a start date.
Getting started

Tags


Find what you came for

We want to make your experience in Hyland Connect as valuable as possible, so we put together some helpful links.