Workflow task shows “Only assigned user can complete” / “Task no longer exists” when multiple roles can approve

0
I have a Mendix workflow where a user task is assigned to two user roles: TIC and Head. The requirement is that any one of these users should be able to approve the enquiry (first come, first serve).Currently, both users can see the task in their inbox. When one user clicks Assign to me and then completes the user task, sometimes it works, but other times I get errors like:“Only assigned user can complete the task”“This user task no longer exists. Another user might have completed it.”I am using the WorkflowCommons module and the AssignTaskToCurrentUser and CompleteUserTask microflows.The task assignment is configured for multiple user roles (TIC and Head).My requirement:Task visible to both TIC and HeadAny one user should be able to approveOnce one user approves, task should complete without errors for othersOther user should not see runtime errors if they open the task after completionQuestions:What is the correct way to configure a workflow user task where multiple roles can approve but only one approval is needed?Is it necessary to use “Assign to me”, or can users directly complete the task?How can I prevent the “task no longer exists” or “only assigned user can complete” errors when multiple users open the same task?Any best practices for handling this scenario in Mendix workflows would be appreciated.
asked
3 answers
0

Hi,


This is expected behavior in Mendix Workflows and is caused by a race condition, not a configuration bug.

What’s really happening


  1. A User Task can only be completed by the user assigned to it at runtime

When a task is visible to multiple users:

  1. Multiple users can open it at the same time
  2. As soon as one user completes the task, the workflow engine finalizes and removes the task
  3. Any other open session still holding that task reference will correctly receive:

“Only assigned user can complete the task”

“Task no longer exists”

This is by design in Mendix.


Why manually changing assignees does NOT work

Changing the UserTask → Assignee association via a custom microflow does not update the workflow engine state.


So even if:

  • The task appears assigned
  • Completion seems to succeed

The engine still detects an invalid runtime state and throws errors.

This approach is unsupported and should be avoided.


Correct and supported pattern (recommended by Mendix)

For first-come, first-serve approval:

  1. Assign the User Task to multiple roles (TIC, Head, etc.)
  2. Do not use a separate “Assign to me” action
  3. On the Approve button:
  4. Call AssignTaskToCurrentUser
  5. Immediately call CompleteUserTask
  6. Both must be executed in the same microflow

This makes the action atomic, eliminating race conditions.

UI best practice

  1. Do not allow users to keep a task page open indefinitely
  2. After completion, refresh or close the page
  3. Optionally show a message like:

“This task was already completed by another user.”

Key takeaway

  1. Workflow tasks are claimed + completed in one action
  2. Manual reassignment is not supported
  3. Errors seen here are expected behavior, not bugs
  4. This is the official Mendix-recommended pattern for multi-role, single-approval workflows.
answered
2

Problem:

This is a race condition. Multiple users can open the same task. When one user completes it, the task becomes invalid for others, causing errors like “Only assigned user can complete the task” or “Task no longer exists”. This is expected behavior.


Solution:

For a first-come, first-serve setup, make the task visible to both roles, but assign and complete it in one single action. Call AssignTaskToCurrentUser and immediately CompleteUserTask in the same microflow. Avoid a separate “Assign to me” step.


Result:

The first user completes the task, and other users won’t hit runtime errors if they open it later.


answered
0

What if I have different users that have the same UserRole? Would any user be able to complete the task without getting the error “Only assigned user can complete the task” or “Task no longer exists”?


This is my use case, I have a user creating the task, he does 2 or three tasks, and it chooses a time to run the third tasks for a time of 8-200 hours typically. Then the next user with the same UserRole comes hours later to continue with the following task in the workflow.


This how I am assigning the User that should be able to complete the tasks.
[( System.UserRoles = '[%UserRole_Operator%]' )]



answered