How to delete a process definition in Tasklist

I have created and deployed some test projects and they are accessible in Processes in Tasklist. Now I want to delete them but I don’t know how it can be done.
I have cancelled every single instance of the processes using the Operate component. But the process still can be started in Tasklist. How can I remove it?

Update: I realized I could do this via Operate. I can select the process and its version, then I can delete the entire process along with its instances. But sometimes a process has over 100 versions. In this situation, do I really have to delete them one by one?

Hello @okaeiz
You can delete either using operate, or another way is using Zeebe API, which would help to delete multiple process deifinitions on your case (considering you are using version 8.5+)

The docs that relates to your question is avaliable on this page:
Resource deletion | Camunda 8 Docs.

For the Resource deletion on Zeebe API:

1 Like

Could you please provide a sample DELETE request? I am using Camunda 8.5 and I couldn’t form the correct API request. @nathansandi

Hi @okaeiz , you can use zbctl

zbctl delete resource $process_def_key

Add --insecure option if you don’t use TLS .
please refer to this documentation for more details CLI client | Camunda 8 Docs

Best Regards
Houssain

1 Like

Hey there @houssain-barouni ! Thanks for the help.
I used the command you mentioned; I put the process definition key (which I defined in Modeler) after the $ symbol but it produced the following error:

Error: expects key as only positional argument

Have you tried the same command but without the $ symbol?

Yeah @Alex_Voloshyn ! It produces a parsing error. I don’t know what to do.

Can you share the error message?

I entered this:

zbctl delete resource carPolicyRequest

And I got this:

Error: invalid argument "carPolicyRequest" for "key": strconv.ParseInt: parsing "carPolicyRequest": ...

What is the version of zbtcl?

zbctl version

zbctl 8.4.0 (commit fdb78794)

Do you use self-managed or on-cloud Camunda?

We’re using Camunda 8 self-managed deployed using docker-compose. I guess the resource key is something different than the process definition key; and I don’t know how to retrieve it for my processes.

You can use this API to figure out the process definition key Get process instance by key | Camunda 8 Docs

Try it with some process instance and in response you get “processDefinitionKey”.

So, I understand that the processDefinitionKey is not what I defined in the Modeler and is shown under the process name in Tasklist. Is that correct?

I think the process definition key is different but that API call will help you to get the correct one.

I used this Zeebe client Github repo which provides a proto file that can be imported into Postman. I created a gRPC request and using createProcessInstance method, I was able to find out what the processDefinitionKey of my process was.
This was the request payload:

{
  "bpmnProcessId": "<my_process_ID>",
  "version": -1
}

And this was the response:

{
    "processDefinitionKey": "2251799828496383",
    "bpmnProcessId": "<my_process_ID>",
    "version": 58,
    "processInstanceKey": "2251799829297853",
    "tenantId": "<default>"
}

So I found the processDefinitionKey using which I could run the following zbctl command:

sudo zbctl --insecure delete resource 2251799828496383 --address=localhost:26500

and it deleted the process definition (all its versions). But there’s still an issue: This command doesn’t work if the process has running instances and it says:

Error: rpc error: code = FailedPrecondition desc = Command 'DELETE' rejected with code 'INVALID_STATE':
Expected to delete resource with key `2251799828496383` but there are still running instances

And since we cannot delete all instances using zbctl or Postman gRPC requests, basically we cannot delete a process definition unless we use Operate to cancel all the instances first, which is possible, and then use zbctl to delete the resource. If you confirm what I understood, we can consider this comment as the solution, I guess.

Yes, you can either Cancel or Complete running instances. And then delete the process definition to delete all the instances.

Regards,
Alex

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.