Reference : Accessing the retry attempt for a failedJobRetryTimeCycle config during execution
I am using the query below to fetch the number of retries for a service task
var retriesNumber = execution.getProcessEngineServices().getManagementService()
.createJobQuery()
.activityId(execution.getCurrentActivityId())
.singleResult()
.getRetries();
However, in a multi-instance loop I get the exception as below when creating incident :
org.camunda.bpm.engine.ProcessEngineException: Query return 2 results instead of max 1
at org.camunda.bpm.engine.impl.AbstractQuery.executeSingleResult(AbstractQuery.java:211)
at org.camunda.bpm.engine.impl.AbstractQuery.execute(AbstractQuery.java:167)
at org.camunda.bpm.engine.impl.interceptor.CommandExecutorImpl.execute(CommandExecutorImpl.java:24)
at org.camunda.bpm.engine.impl.interceptor.CommandContextInterceptor.execute(CommandContextInterceptor.java:104)
at org.camunda.bpm.engine.impl.interceptor.ProcessApplicationContextInterceptor.execute(ProcessApplicationContextInterceptor.java:66)
at org.camunda.bpm.engine.impl.interceptor.LogInterceptor.execute(LogInterceptor.java:30)
at org.camunda.bpm.engine.impl.AbstractQuery.singleResult(AbstractQuery.java:130)
at com
How to fix this query for multi-instance?