How to store the Task ID while the User Task is created
I have a requirement to store the Task ID of a User Task in one asset attribute as soon as the Task is created. Can this be achieved using Task Listener? If yes, how?
Asif Rasul
Posted 6 months ago · Edited 6 months ago·Last reply 6 months ago
5 comments
Asif Rasul
OP6 months agoHi @Sean Pyle ,
Thank you for the new approach. But one change is required for my requirement. I cannot have Timer specific triggers to send notification instead the trigger will come from manual triggers. Can you please suggest how to have this option for the approach you provided?
Regards
Asif
Sean Pyle
·6 months ago · EditedUnderstood, in that case I'll stick with the approach you wanted to take. Here's how you can capture the task ID (I assume you can manage setting up the other workflow where someone uses it).
In your workflow with the stalled user task, use a Parallel Gateway and a Task ID Variable.
1. In the Start Event properties, add a new Form Property:
Id:
taskIdAttributeTypeIdName: Task ID Attribute Type UUID
Type:
stringDefault: (Paste your Attribute Type UUID here..probably create a custom one to store the UUID – For test purposes I just stored it in the asset's description)
Writable:
true(Keep it hidden so users don't see it).2.Setup the User Task
Click your User Task in the designer and set these two properties in the configuration bar:
Task ID variable:
createdTaskIdAsynchronous:
true3. The BPMN Layout
Split your flow with a Parallel Gateway.
Branch A: Goes to your User Task (where the user sits and works).
Branch B: Goes to a Script Task (your "Capture" script) and then ends.
4. The "Capture" Script
In that Branch B script, you just grab that
createdTaskId(which is now a global variable) and shove it into a Collibra attribute on the asset.import com.collibra.dgc.core.api.dto.instance.attribute.AddAttributeRequest import com.collibra.dgc.core.api.dto.instance.attribute.FindAttributesRequest // Workflow Designer makes 'createdTaskId' available to us automatically! if (createdTaskId != null) { // Get your Attribute Type UUID from your Start Form property def attrTypeUuid = string2Uuid(taskIdAttributeTypeId) // Check if we need to add or update the Task ID on the asset def existing = attributeApi.findAttributes(FindAttributesRequest.builder() .assetId(item.getId()) .typeIds([attrTypeUuid]).build()).getResults() if (existing.isEmpty()) { attributeApi.addAttribute(AddAttributeRequest.builder() .assetId(item.getId()) .typeId(attrTypeUuid) .value(createdTaskId).build()) loggerApi.info("Locked Task ID " + createdTaskId + " onto the asset.") } }Justin Truehitt
·6 months agoIf the only need to store the task ID is to drive notifications, have you considered establishing a separate workflow that sends bulk reminder notifications instead? Our approach has been to establish an entirely separate workflow that sends an individual "reminder" email to each user with open tasks at run time (combining all tasks in to a single email, sorted and grouped by due date). We're running this once a week to notify/remind of open tasks in a consolidated fashion to get around all of the notification challenges within Flowable.
Sean Pyle
·6 months agoHello Asif,
Manually storing Task IDs to trigger reminders adds a lot of "state management" overhead that you probably don't need. If you go that route, you’ll eventually run into race conditions—like sending a reminder for a task that was completed seconds ago.
Instead of managing Task IDs and external attributes, I’d recommend using a Non-Interrupting Timer Boundary Event attached directly to your User Task. It handles the "is the task still there?" logic automatically.
Why this is usually the better path:
Automatic Cleanup: If the user completes the task, the timer is automatically cancelled by the engine. No "ghost" reminders.
Zero Custom Code: You don't need Task Listeners or external attribute storage.
Visibility: Anyone looking at your BPMN diagram can see exactly when and how often reminders are sent.
How to set it up
Attach a Timer: Drag a Boundary Event onto your User Task and set it to Non-Interrupting (it will look like a dashed double-circle).
Set the Duration: Use an ISO 8601 duration. For example,
PT24Hsends a reminder after 24 hours.Route to a Script Task: Connect the timer to a Script Task (or Email Task) that sends the reminder.
End the Flow: Point the Service Task to an End Event. Because the timer is non-interrupting, the main User Task stays active!
Asif Rasul
OP6 months agoAdding more context.
Our workflow has a User Task. This Task gets assigned to users who takes their own time to work on it. What we want is to keep track of the Task Id in an attribute and later we want to invoke another workflow manually to send reminder if the Task Id is present. If the Task Id is not present then we start the first workflow to create a User Task.
The issue I am facing is that when a User Task is generated and stays there without the user taking action then the process execution stays at the User Task. How do I invoke a custom logic to store the Task ID in an attribute as soon as the User Task is created?