Number of pending tasks of a user

Hi,

I'm trying to create a process where a user can specify a number of pending task and days so he receives a notification after that number of days while he has X number of tasks.

For that I'm trying to get the number of pending tasks of the user with getNumberOfPendingHumanTaskInstances(userID) where userID is the ID of the user. I'm trying to save the resulting long in a Process Variable but it's throwing this error and I'm not sure what's up:

29-Oct-2020 16:16:34.387 GRAVE [Bonita-Worker-1-10] org.bonitasoft.engine.log.technical.TechnicalLoggerSLF4JImpl.log THREAD_ID=151 | HOSTNAME=------------- | TENANT_ID=1 | org.bonitasoft.engine.core.process.instance.api.exceptions.SActivityStateExecutionException : "PROCESS_DEFINITION_ID=7236803231010661546 | PROCESS_NAME=Notificación de tareas pendientes | PROCESS_VERSION=1.0 | PROCESS_INSTANCE_ID=3012 | ROOT_PROCESS_INSTANCE_ID=3012 | FLOW_NODE_DEFINITION_ID=7952628545421029278 | FLOW_NODE_INSTANCE_ID=60031 | FLOW_NODE_NAME=Tarea2 | org.bonitasoft.engine.core.operation.exception.SOperationExecutionException: org.bonitasoft.engine.expression.exception.SExpressionEvaluationException: groovy.lang.MissingMethodException: No signature of method: BScript29.getNumberOfPendingHumanTaskInstances() is applicable for argument types: (java.lang.Long) values: [22]"
    org.bonitasoft.engine.core.process.instance.api.exceptions.SActivityStateExecutionException: PROCESS_DEFINITION_ID=7236803231010661546 | PROCESS_NAME=Notificación de tareas pendientes | PROCESS_VERSION=1.0 | PROCESS_INSTANCE_ID=3012 | ROOT_PROCESS_INSTANCE_ID=3012 | FLOW_NODE_DEFINITION_ID=7952628545421029278 | FLOW_NODE_INSTANCE_ID=60031 | FLOW_NODE_NAME=Tarea2 | org.bonitasoft.engine.core.operation.exception.SOperationExecutionException: org.bonitasoft.engine.expression.exception.SExpressionEvaluationException: groovy.lang.MissingMethodException: No signature of method: BScript29.getNumberOfPendingHumanTaskInstances() is applicable for argument types: (java.lang.Long) values: [22]
        at org.bonitasoft.engine.execution.StateBehaviors.executeOperations(StateBehaviors.java:652)
        at org.bonitasoft.engine.execution.state.ExecutingAutomaticActivityStateImpl.onEnterToOnFinish(ExecutingAutomaticActivityStateImpl.java:50)
        at org.bonitasoft.engine.execution.state.OnEnterAndFinishConnectorState.execute(OnEnterAndFinishConnectorState.java:74)
        at org.bonitasoft.engine.execution.state.OnEnterAndFinishConnectorState.execute(OnEnterAndFinishConnectorState.java:33)
        at org.bonitasoft.engine.execution.FlowNodeExecutorImpl.executeState(FlowNodeExecutorImpl.java:121)
        at org.bonitasoft.engine.execution.FlowNodeExecutorImpl.updateState(FlowNodeExecutorImpl.java:179)
        at org.bonitasoft.engine.execution.FlowNodeExecutorImpl.stepForward(FlowNodeExecutorImpl.java:160)
        at org.bonitasoft.engine.execution.FlowNodeExecutorImpl.executeFlowNode(FlowNodeExecutorImpl.java:337)
        at org.bonitasoft.engine.execution.work.ExecuteFlowNodeWork.work(ExecuteFlowNodeWork.java:73)
        at org.bonitasoft.engine.execution.work.TxBonitaWork.lambda$work$0(TxBonitaWork.java:41)
        at org.bonitasoft.engine.transaction.JTATransactionServiceImpl.executeInTransaction(JTATransactionServiceImpl.java:286)
        at org.bonitasoft.engine.execution.work.TxBonitaWork.work(TxBonitaWork.java:41)
        at org.bonitasoft.engine.execution.work.LockProcessInstanceWork.work(LockProcessInstanceWork.java:68)
        at org.bonitasoft.engine.execution.work.failurewrapping.TxInHandleFailureWrappingWork.work(TxInHandleFailureWrappingWork.java:40)
        at org.bonitasoft.engine.execution.work.failurewrapping.TxInHandleFailureWrappingWork.work(TxInHandleFailureWrappingWork.java:40)
        at org.bonitasoft.engine.execution.work.failurewrapping.TxInHandleFailureWrappingWork.work(TxInHandleFailureWrappingWork.java:40)
        at org.bonitasoft.engine.execution.work.InSessionBonitaWork.work(InSessionBonitaWork.java:60)
        at org.bonitasoft.engine.work.BonitaThreadPoolExecutor.lambda$submit$1(BonitaThreadPoolExecutor.java:131)
        at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
        at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
        at java.base/java.lang.Thread.run(Unknown Source)
    Caused by: org.bonitasoft.engine.core.operation.exception.SOperationExecutionException: org.bonitasoft.engine.expression.exception.SExpressionEvaluationException: groovy.lang.MissingMethodException: No signature of method: BScript29.getNumberOfPendingHumanTaskInstances() is applicable for argument types: (java.lang.Long) values: [22]
        at org.bonitasoft.engine.core.operation.impl.OperationServiceImpl.evaluateRightOperandExpression(OperationServiceImpl.java:228)
        at org.bonitasoft.engine.core.operation.impl.OperationServiceImpl.calculateRightOperandValue(OperationServiceImpl.java:133)
        at org.bonitasoft.engine.core.operation.impl.OperationServiceImpl.executeOperators(OperationServiceImpl.java:114)
        at org.bonitasoft.engine.core.operation.impl.OperationServiceImpl.execute(OperationServiceImpl.java:101)
        at org.bonitasoft.engine.core.operation.impl.OperationServiceImpl.execute(OperationServiceImpl.java:85)
        at org.bonitasoft.engine.execution.StateBehaviors.executeOperations(StateBehaviors.java:649)
        ... 20 more
    Caused by: org.bonitasoft.engine.expression.exception.SExpressionEvaluationException: groovy.lang.MissingMethodException: No signature of method: BScript29.getNumberOfPendingHumanTaskInstances() is applicable for argument types: (java.lang.Long) values: [22]
        at org.bonitasoft.engine.expression.impl.GroovyScriptExpressionExecutorCacheStrategy.evaluate(GroovyScriptExpressionExecutorCacheStrategy.java:152)
        at org.bonitasoft.engine.expression.impl.ExpressionServiceImpl.evaluate(ExpressionServiceImpl.java:89)
        at org.bonitasoft.engine.core.expression.control.api.impl.ExpressionResolverServiceImpl.evaluateExpressionWithResolvedDependencies(ExpressionResolverServiceImpl.java:234)
        at org.bonitasoft.engine.core.expression.control.api.impl.ExpressionResolverServiceImpl.evaluateExpressionsFlatten(ExpressionResolverServiceImpl.java:127)
        at org.bonitasoft.engine.core.expression.control.api.impl.ExpressionResolverServiceImpl.evaluate(ExpressionResolverServiceImpl.java:86)
        at org.bonitasoft.engine.core.operation.impl.OperationServiceImpl.evaluateRightOperandExpression(OperationServiceImpl.java:221)
        ... 25 more
    Caused by: groovy.lang.MissingMethodException: No signature of method: BScript29.getNumberOfPendingHumanTaskInstances() is applicable for argument types: (java.lang.Long) values: [22]
        at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.unwrap(ScriptBytecodeAdapter.java:71)
        at org.codehaus.groovy.runtime.callsite.PogoMetaClassSite.callCurrent(PogoMetaClassSite.java:80)
        at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCallCurrent(CallSiteArray.java:51)
        at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:157)
        at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:169)
        at BScript29.run(BScript29.groovy:1)
        at org.bonitasoft.engine.expression.impl.GroovyScriptExpressionExecutorCacheStrategy.evaluate(GroovyScriptExpressionExecutorCacheStrategy.java:145)
        ... 30 more

Hola,

Obviously, you are using an Operation with a Groovy script to do that, but the right operand expression fails to evaluate the groovy script.

Can you provide me with the content of the script?

Groovy complains that:

no method getNumberOfPendingHumanTaskInstances() is applicable for argument types: (java.lang.Long) values: [22]

If this is a call to Bonita Engine API, can you ensure your parameter is of type Long (and not Integer, for instance)?

Hope this helps,

Emmanuel