apiAccessor does not work in a connector email

1
0
-1

Hi everyone,

I have had a problem with apiAccessor that didn't work in a connector email. Here is the error message :

org.bonitasoft.engine.expression.exception.SExpressionEvaluationException: PROCESS_DEFINITION_ID=8925647421307834808 | PROCESS_NAME=ProcessusDemandeAchat | PROCESS_VERSION=1.1.0 | PROCESS_INSTANCE_ID=18456 | ROOT_PROCESS_INSTANCE_ID=18456 | FLOW_NODE_DEFINITION_ID=6173078484248163996 | FLOW_NODE_INSTANCE_ID=406103 | FLOW_NODE_NAME=notifierPrescripteurCFMRefusRCFMDA | CONNECTOR_IMPLEMENTATION_CLASS_NAME=cDA_E75_NotifierDemandeurRefusRCFM | CONNECTOR_INSTANCE_ID=274119 | Expression ccPrescripteurRPB() with content =

String emailRPB = apiAccessor.getIdentityAPI().getUserContactData(demandeAchat?.bonita_rpb_id, false)?.getEmail();

if(demandeAchat?.bonita_prescripteur_id == demandeAchat?.bonita_demandeur_id){
return emailRPB;
}

return demandeAchat?.prescripteur_email + "," + emailRPB;> depends on apiAccessor is neither defined in the script nor in dependencies.
at org.bonitasoft.engine.expression.impl.GroovyScriptExpressionExecutorCacheStrategy.evaluate(GroovyScriptExpressionExecutorCacheStrategy.java:148)
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.connector.impl.ConnectorServiceImpl.evaluateInputParameters(ConnectorServiceImpl.java:344)
at org.bonitasoft.engine.connector.ConnectorServiceDecorator.evaluateInputParameters(ConnectorServiceDecorator.java:112)
at org.bonitasoft.engine.execution.work.ExecuteConnectorWork$EvaluateParameterAndGetConnectorInstance.call(ExecuteConnectorWork.java:260)
at org.bonitasoft.engine.execution.work.ExecuteConnectorWork$EvaluateParameterAndGetConnectorInstance.call(ExecuteConnectorWork.java:218)
at org.bonitasoft.engine.transaction.JTATransactionServiceImpl.executeInTransaction(JTATransactionServiceImpl.java:286)
at org.bonitasoft.engine.execution.work.ExecuteConnectorWork.work(ExecuteConnectorWork.java:148)
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.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(ThreadPoolExecutor.java:1128)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
at java.base/java.lang.Thread.run(Thread.java:834)
Caused by: groovy.lang.MissingPropertyException: No such property: apiAccessor for class: BScript705
at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.unwrap(ScriptBytecodeAdapter.java:66)
at org.codehaus.groovy.runtime.callsite.PogoGetPropertySite.getProperty(PogoGetPropertySite.java:51)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callGroovyObjectGetProperty(AbstractCallSite.java:310)
at BScript705.run(BScript705.groovy:3)
at org.bonitasoft.engine.expression.impl.GroovyScriptExpressionExecutorCacheStrategy.evaluate(GroovyScriptExpressionExecutorCacheStrategy.java:145)
... 19 more

The code is used in email connector and in the "Other -> CC" section :

import org.bonitasoft.engine.api.IdentityAPI

String emailRPB = apiAccessor.getIdentityAPI().getUserContactData(demandeAchat?.bonita_rpb_id, false)?.getEmail();

if(demandeAchat?.bonita_prescripteur_id == demandeAchat?.bonita_demandeur_id){
return emailRPB;
}

return demandeAchat?.prescripteur_email + "," + emailRPB;

I would be grateful if you have any ideas of this error. Thank you in advance !!!

Tuan-Anh LE

1 answer

1
0
-1
This one is the BEST answer!

Hi,

You can try to open the script editor of your email body input and uncheck the automatic dependencies resolution checkbox. It should list the apiAccessor variable. If not, you can add it manually or try to check/uncheck this checkbox to see if it resolves the dependencies properly.

HTH
Romain

Comments

Submitted by tuan-anh.le on Wed, 05/18/2022 - 10:08

Hello Romain,

Thank you for your answer and suggestion !

Effectively, i have had a problem with the dependencies because I have copied and pasted my code from an editor to another editor script. Sometimes, Bonita studio has the difficulties to generate automatically the dependencies.

So the problem is solved. Have a nice day !

Best regards,

Tuan-Anh

Notifications