Custom Notifications on unwanted user task assignments

Hi there,

I have a process application using camunda tasklist and embedded forms and I need to prevent specific users being assigned to specific user tasks. The business requirement is: the initiator of a process needs to see an approval task in his tasklist (to see who is working on it) but may not claim this task himself. The username of the initiator is provided as a process variable and I’m using (something like) the following task listener to prevent the assignment:

@Component
@Slf4j
public class PreventAssignmentListener implements TaskListener {

    @Override
    public void notify(DelegateTask delegateTask) {
        if ("horst".equalsIgnoreCase(delegateTask.getAssignee())) {
            throw new RuntimeException("User 'horst' is not allowed to claim this task!");
        }
        log.info("Assigned task to {}", delegateTask.getAssignee());
    }
}

So far, so good – it works. But now I don’t want to see the standard error overlay to be shown in the tasklist web app but trigger a custom notification. Any ideas how I can achieve this?

Thanks & Cheers…
Jo

Do you meant want to send email notification about assignment?

No, not an e-mail. I am thinking of a customized Toast notification in the tasklist webapp (instead of the standard error message that’s shown when an exception occurs)

Hi @joehm,

we do some messaging in our demo showcase: https://github.com/camunda-consulting/showroom-customer-onboarding/blob/master/src/main/resources/static/forms/decide_de.html#L313-L320

Maybe you can adopt this?

Hope this helps, Ingo

Hi @Ingo_Richtsmeier ,

thanks – that was exactly what I was thinking of. However, how can I trigger it from a task listener? I have already tried by means of taskService.handleBpmnError(..) and then try to catch it in the embedded form like this:

camForm.on('error', function(evt) {
      evt.errorPrevented = true;
      inject(['Notifications', function(Notifications) {
            Notifications.addMessage({
                  status: 'Forbidden!',
                  message: 'The creator of this task cannot be assigned to it!',
                  unsafe: true
            });
      }]);      
});

but that didn’t work. The BPMN error was not caught and the execution was just aborted.

Cheers… Jo