cancel
Showing results for 
Search instead for 
Did you mean: 

How get task from business key

aram
Champ in-the-making
Champ in-the-making
Hi.
I am using grails activity plugin. and I like to get all tasks for current document.
to do that I define domain classes "Task" and "Execution" in grains and use following HQL

getTaskForDocument = from Task
where id in(
select id from Task where EXECUTION_ID_ in(
select exec1.id from Execution exec1 where
exec1.BUSINESS_KEY_=:BUSINESS_KEY and
exec1.id in( select max(id) from Execution as exec2 where exec2.BUSINESS_KEY_ = exec1.BUSINESS_KEY_ )))

List tasksForDocument = Task.findAll(getTaskForDocument, [BUSINESS_KEY: "BUSINESS_KEY_here"]);

Is there any other effective way to get Task using BUSINESS_KEY (I don't like to have/define  "Task" and "Execution" domain classes in my app)?
2 REPLIES 2

ronald_van_kuij
Champ on-the-rise
Champ on-the-rise
Is there any other effective way to get Task using BUSINESS_KEY (I don't like to have/define "Task" and "Execution" domain classes in my app)?

Define effective… I just use the Activiti api and it performs well…

aram
Champ in-the-making
Champ in-the-making
using API I implement

public List<Task> getTasksFromDocumentID(String documentId) {
        List<Execution> executions = ActivitiUtils.getRuntimeService().createExecutionQuery()
                .variableValueEquals('businessKey', documentId)
                .orderByProcessInstanceId().desc().list();
       
        if (executions.size() > 0) {
            return ActivitiUtils.getTaskService().createTaskQuery()
                    .processInstanceId(executions.get(0)?.getProcessInstanceId())
                    .list();
        } else {
            return new ArrayList<Task>();
        }

    }

but here I have 2 querys. Is it possible to have only one query ?
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.