To email field in email connector

Hello,
I am configuring email connector, in to email I want to write initiator’s email. For example, when first initiator runs case in to email field should be filled by first initiator’s email, when other initiator runs case to email should be filled with its email automatically, is it possible ?

Hi,
Try this and store the value in a process variable, this variable will be use in email connector:

import org.bonitasoft.engine.identity.User;

return BonitaUsers.getProcessInstanceInitiatorManagerPersonalContactInfo(apiAccessor, processInstanceId).email;

Have a good dev!
Franck,

it shows following exception

java.lang.reflect.InvocationTargetException
org.bonitasoft.engine.bpm.connector.ConnectorExecutionException: USERNAME=install | org.bonitasoft.engine.core.connector.exception.SConnectorException: org.bonitasoft.engine.expression.exception.SExpressionEvaluationException: Groovy script throws an exception of type class org.bonitasoft.engine.bpm.process.ProcessInstanceNotFoundException with message = org.bonitasoft.engine.core.process.instance.api.exceptions.SProcessInstanceNotFoundException: Process instance with id <-1> not found

Expression : SExpressionImpl [name=to(), content=import org.bonitasoft.engine.identity.User;

return BonitaUsers.getProcessInstanceInitiatorManagerPersonalContactInfo(apiAccessor, processInstanceId).email;, returnType=java.lang.String, dependencies=[SExpressionImpl [name=processInstanceId, content=processInstanceId, returnType=java.lang.Long, dependencies=, expressionKind=ExpressionKind [interpreter=NONE, type=TYPE_ENGINE_CONSTANT]], SExpressionImpl [name=apiAccessor, content=apiAccessor, returnType=org.bonitasoft.engine.api.APIAccessor, dependencies=, expressionKind=ExpressionKind [interpreter=NONE, type=TYPE_ENGINE_CONSTANT]]], expressionKind=ExpressionKind [interpreter=GROOVY, type=TYPE_READ_ONLY_SCRIPT]]