Unable to execute a User Task - Getting error

Hello Community

I am trying to execute a User task using the below code.

 

Map m = new HashMap<>();
//m.put('name','Test');
//m.put('email','Test@vodafone.qa');
//m.put('phone',"14-2");
//m.put('address','Yes');

long userTaskInstanceId = 100016
apiAccessor.processAPI.executeUserTask(userTaskInstanceId, m)

return "done";

But i am getting the below error

return "done";, returnType=java.lang.String, dependencies=[SExpressionImpl [name=apiAccessor, content=apiAccessor, returnType=com.bonitasoft.engine.api.APIAccessor, dependencies=[], expressionKind=ExpressionKind [interpreter=NONE, type=TYPE_ENGINE_CONSTANT]]], expressionKind=ExpressionKind [interpreter=GROOVY, type=TYPE_READ_ONLY_SCRIPT]]
        at org.bonitasoft.engine.expression.impl.GroovyScriptExpressionExecutorCacheStrategy.evaluate(GroovyScriptExpressionExecutorCacheStrategy.java:169)
        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: org.bonitasoft.engine.bpm.flownode.FlowNodeExecutionException: org.bonitasoft.engine.transaction.STransactionCreationException: We do not support nested calls to the transaction service. Current state is: 0. 
        at org.bonitasoft.engine.api.impl.ProcessAPIImpl.verifyIfTheActivityWasInTheCorrectStateAndThrowException(ProcessAPIImpl.java:6318)
        at org.bonitasoft.engine.api.impl.ProcessAPIImpl.executeUserTask(ProcessAPIImpl.java:6294)
        at org.bonitasoft.engine.api.impl.ProcessAPIImpl.executeUserTask(ProcessAPIImpl.java:6275)
        at org.bonitasoft.engine.api.ProcessRuntimeAPI$executeUserTask.call(Unknown Source)
        at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:47)
        at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:116)
        at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:136)
        at BScript4.run(BScript4.groovy:49)
        at org.bonitasoft.engine.expression.impl.GroovyScriptExpressionExecutorCacheStrategy.evaluate(GroovyScriptExpressionExecutorCacheStrategy.java:145)
        ... 30 more
    Caused by: org.bonitasoft.engine.transaction.STransactionCreationException: We do not support nested calls to the transaction service. Current state is: 0. 
        at org.bonitasoft.engine.transaction.JTATransactionServiceImpl.checkForNestedBonitaTransaction(JTATransactionServiceImpl.java:142)
        at org.bonitasoft.engine.transaction.JTATransactionServiceImpl.begin(JTATransactionServiceImpl.java:79)
        at org.bonitasoft.engine.transaction.JTATransactionServiceImpl.executeInTransaction(JTATransactionServiceImpl.java:284)
        at org.bonitasoft.engine.api.impl.ProcessAPIImpl.inTx(ProcessAPIImpl.java:6322)
        at org.bonitasoft.engine.api.impl.ProcessAPIImpl.executeUserTask(ProcessAPIImpl.java:6284)
        ... 37 more

Never mind

I put the code in Groovy connector and it works perfectly fine

thanks