Current Task via Engine API

Hi, it is possible get de "current" task in workflow via engine api just given the process id ou case id?

 

Thanks,

Diana

Hi,

You can use search API (in REST or either the Java API) to filter a case 'READY' tasks.

In java/groovy:

import org.bonitasoft.engine.bpm.flownode.ActivityStates import org.bonitasoft.engine.bpm.flownode.HumanTaskInstanceSearchDescriptor import org.bonitasoft.engine.search.SearchOptionsBuilder

def processAPI = apiAccessor.processAPI
def searchResult = processAPI.searchHumanTaskInstances(new SearchOptionsBuilder(0, 10)
.filter(HumanTaskInstanceSearchDescriptor.PROCESS_INSTANCE_ID, 1L)
.filter(HumanTaskInstanceSearchDescriptor.STATE_NAME, ActivityStates.READY_STATE)
.done())

In Rest:

/API/bpm/userTask?c=10&p=0&f=caseId=1&f=state=ready 

HTH

Romain