Custom task list using process instance variable

I am trying to implement a purchase order (PO) workflow using a React front end. I have a listing page for showing all the POs. As per the suggested answer to my previous question, I have implemented a status variable in camunda process instance to capture the current milestone/stage of the instance. Some of the PO data is on my application database, and I have added the processInstanceId as a reference to each instance in camunda.

Right now I am fetching all the entries from my db, and then subsequently making a bunch of REST API calls to get the status variable - http://localhost:1234/engine-rest/process-instance/processInstanceId/variables. This works fine for processes that are running. However for instances that are not running, I am getting a server 500 error. Is there any way to generalize accessing the status variable? Thanks :slightly_smiling_face:

image

Link to previous question explaining use case - How can I get the process definition tasks through API - #4 by Niall

Hi @johnjacobkenny,

Use (/history/activity-instance) subresource instead and filter by both variableName and processInstanceId.
This should do the job for both running and finished instances.

GET version:
https://docs.camunda.org/manual/latest/reference/rest/history/variable-instance/get-variable-instance-query/

POST version:
https://docs.camunda.org/manual/latest/reference/rest/history/variable-instance/post-variable-instance-query/

Thanks, this worked! :smiley: