Hello,
I’m trying to use the java code from the example
https://github.com/camunda/camunda-bpm-examples/tree/master/usertask/task-assignment-email
in the task of my process, because I want that the target user must to have notification email on task assignement. I don’t have changed the java code, I’ve just only changed the credentials of smtp server
I cannot understand why I receive t
wo mail instead of one mail.
I upload also my BPMN if you want verify the configuration
inserimento_assegnazione_v3.bpmn (25.8 KB)
1 Like
In the process execution flow, if this two steps (setta_variabili, Modifica richiesta) got executed means then there’s a chance to get executed twice of this org.camunda.bpm.quickstart.TaskAssignmentListener
In short, number of times the execution token arrives at the activity Approvazione primo livello richiesta, it will trigger that many times of the configured listener in that activity
Hello @aravindhrs, when my process start the user fill a form. After I need the service task “setta_variabili” to
only for setting variable that i use in exclusive gateway
package org.camunda.bpm.quickstart;
import org.camunda.bpm.engine.delegate.DelegateExecution;
import org.camunda.bpm.engine.delegate.JavaDelegate;
public class CheckApprovatoreDelegate implements JavaDelegate {
@Override
public void execute(DelegateExecution execution) throws Exception {
// TODO Auto-generated method stub
execution.setVariable("secondo", false);
execution.setVariable("approvato", false);
execution.setVariable("modifica", false);
execution.setVariable("approvato2", false);
execution.setVariable("revocato", false);
execution.setVariable("causale_ok", false);
After there is my task ( Approvazione richiesta primo livello) with Task Listener so I don’t understand why taskAssignementListener have executed twice
can you provide the flow of execution token of your process for the scenario where listener got triggered two times?
I hope I understand your request:
- The user “dipendente” starts a new task ( “Inserimento richiesta”) and fills in the form and completes the task
- The service task is started to set the variables ( “setta_variabili”)
- The target task ( “Approvazione primo livello richiesta” ) is assigned to the user “responsabile1”
- 2 emails are generated instead of 1 and sent to user “responsabile1”
@oronzo_lezzi in the usertask approva_Richiesta , there’s a listener attached as a script at eventType=‘create’ two times, and in both (ticked) scripts, you’re setting assignee. So that’s the reason assignment listener got triggered two times and you received two emails.
The scripts you configured are,
if(!!task.getVariable('approver')) {
task.setAssignee(approver); // ==> triggered 1st email on assignment
}
if(!!task.getVariable('dateApprove')) {
task.setAssignee(dateApprove); // ==> triggered 2nd email on assignment
}
So whenever you set assignee, the assignment listener will trigger that many number of times. This is expected behaviour.
Number of times the task is assigned to user is directly proportional to Number of times task assigned to user
2 Likes
Good morning @aravindhrs thank you for your suggest. I have removed this script and now I have only one mail.
I will try to obtain the variable ‘approver’ and ‘dateApprove’ in other way.