Managing request status through workflow

Hello all,

I’m trying to use Camunda workflow to manage the requests within my application. I’m having a tough time right now deciding how to track the status of the request as it goes through the workflow. The status could be one of the following: PENDING, APPROVED, REJECTED, CANCELED, or REVOKED.

I understand I can create a process variable called status and update this value as it goes through my workflow.

execution.setVariable("status", RequestStatus.PENDING);

When I try to retrieve all requests according to the request status from my APIs, would I use Camunda’s HistoryService to get HistroricProcessInstances by my ProcessDefinitionKey and process variable “status” = “{DESIRED_STATUS}”? Or is there a better way to retrieve my requests according to their status?

In my workflow, PENDING requests will be considered active process instances and APPROVED, REJECTED, CANCELED, and REVOKED are process instances that have finished.

Hi @mtn217,

Yes, through history service you can retrieve data related to all instances (running and finished).

But I prefer to have your business data “requests” stored separately as custom database records and to utilize task/execution listeners or service task(s) in the workflow definition to update the status column of corresponding custom record “request”.

1 Like

Got it, this was what I was doing doing initially, but I wasn’t quite sure if this was best practice. By setting the status in the DB I can I can easily query my DB table to fetch my requests according to the status. Thanks @hassang!