25.4.8 Deleting a Workflow with No Instances

Check whether any workflow instances still use a version before deleting it.

Workflow versions let your business process evolve over time. Every workflow instance created outside of Development Mode uses the Active version at the time of creation. The WORKFLOW_VERSION column in the APEX_WORKFLOWS dictionary view reflects the version each instance uses. A given workflow instance continues using the workflow version it was created with throughout its lifecycle.

If you activate a new version, this only affects new workflow instances. An Inactive version does not mean an Unused version. It only means no new workflow instances will use that inactive version.

In addition to deactivating previous workflow versions, the Workflow Builder also lets you delete workflow versions. However, you must ensure no workflow instances are using that version any more before you delete it. Before deleting a workflow, run the following query in the SQL Workshop > SQL Commands page to verify that the version you are considering deleting is no longer in use.

-- list procedure_lifecycle workflow versions in use
select distinct workflow_version
 from apex_workflows
where application_id = 103
  and workflow_def_static_id = 'procedure_lifecycle'
order by workflow_version

Caution:

Avoid accidentally deleting a workflow version that is still in use by running the above query first!