Email Task URL to user

at the end of TASK 1 i create one email connector

in email body , i switch to script editor and as per documentation i paste following code ,

StringBuffer buffer = new StringBuffer(“URL: <a href="”);
buffer.append(“http://”);
buffer.append(host);
buffer.append(“:”);
buffer.append(port);
buffer.append(“/bonita?ui=form&locale=en#form=”);
buffer.append(processName); buffer.append(“–”);
buffer.append(processVersion); buffer.append(“–”);
buffer.append(activityName);
buffer.append(“$entry&mode=app&task=”); <— warning Prompt : entry cannot be resolved. It may lead to runtime errors.
buffer.append(activityInstanceId);
buffer.append(“">here”);
return buffer.toString();

but in editor i gives following warning error .

entry cannot be resolved. It may lead to runtime errors.

i try to run it but connector fails at execution

how to achieve it .

In your line 10, you should add a backslash before $ sign:

buffer.append(“$entry&mode=app&task=”);

It worked fine for me.

Here some changes to use the code in a BonitaBPM script conector to make a link to the current task.

StringBuffer buffer = new StringBuffer(“URL: <a href="”);
buffer.append(“http://”);
buffer.append(“localhost”); // write your server name or IP
buffer.append(“:”);
buffer.append(“8080”); //the port where the server is running
buffer.append(“/bonita?ui=form&locale=es#form=”); //change locale=es by locale=en for english
buffer.append(apiAccessor.processAPI.getProcessInstance(processInstanceId).getName());
buffer.append(“–”);
buffer.append(apiAccessor.processAPI.getProcessDefinition(processDefinitionId).getVersion()); buffer.append(“–”); //version
buffer.append(apiAccessor.processAPI.getActivityInstance(activityInstanceId).getName());
buffer.append(“%24entry&mode=app&task=”); //note I changed $ by %24
buffer.append(activityInstanceId);

buffer.append(“">Click here to go to the task”); //write your own link label
return buffer.toString();

Thank you for answer , i tried to execute give following error

java.lang.reflect.InvocationTargetException
org.bonitasoft.engine.bpm.connector.ConnectorExecutionException: org.bonitasoft.engine.core.connector.exception.SConnectorException: org.bonitasoft.engine.expression.exception.SInvalidExpressionException: Declared return type class java.lang.Long is not compatible with evaluated type class java.lang.Integer for expression activityInstanceId

You have a mismatch in some Groovy script, Return type is declared as Long, while the script returns an Integer value. Try to modify your script or to change the return type of the expression.

how to specify return type in groovy script

i can’t figure out

there is disable return type : java.lang.string
and script’s return type tostring()
what mismatch
how to resolve it

Script provided in the other thread here .

Thank you soo much

I also had the same problem and it was solved just by replacing " with ’