AnsweredAssumed Answered

AlfrescoAssignment and email notifications

Question asked by marco.altieri on Aug 5, 2014
Latest reply on Aug 6, 2014 by marco.altieri
I have written a custom JBPM workflow that for some tasks has to send notifications to the assigned users.

I know how to do it using a custom java action or a simple javascript, but I am trying to use the flag bpm_sendEMailNotifications: if this flag is true, the class org.alfresco.repo.workflow.jbpm.AlfrescoAssignment automatically sends the notifications.

For example the following task in the workflow definition sets the flag to true on the creation of the task.


    <task-node name="finalReview">
        <task name="mswf:reviewTask">
            <assignment class="org.alfresco.repo.workflow.jbpm.AlfrescoAssignment">
               <pooledactors>#{finalReviewReviewer}</pooledactors>
            </assignment>
            <event type="task-create">
                <script>
                    executionContext.setVariable("bpm_sendEMailNotifications", true);
                </script>
            </event>
        </task>
        <transition name="approve" to="endFinalReview"/>
        <transition name="reject" to="endFinalReview"/>
    </task-node>


The transition to this node fails with the following exception:
"07052361 Accessing task with id='jbpm$200957' is not allowed for user 'atc1'"

atc1 is the user that clicks the transition button and it is not the current user assigned to the task.

The exception is thrown by the class WorkflowNotificationUtils when it tries to get the WorkflowTask (at line 168 for Alfresco enterprise version 4.1.7):

WorkflowTask workflowTask = services.getWorkflowService().getTaskById(taskId);

I verified that the task has been already assigned to a different user, as expected.

Outcomes