How to display draft workflows?

Deleted user April 8, 2020

Hi,

I need to delete draft workflows however i didn't find them neither in GUI nor using java api.

Any idea?

Thanks

Ahmed

2 answers

0 votes
ChristopherChilds
Contributor
January 30, 2025
A little late to the party but I think @[deleted] This is what you are after:
import com.atlassian.jira.workflow.WorkflowManager
import com.atlassian.jira.component.ComponentAccessor
def workflowManager = ComponentAccessor.getComponent(WorkflowManager)
def allWorkflows = workflowManager.getWorkflowsIncludingDrafts()
return (allWorkflows.each {it -> it.isDraftWorkflow()}).name
0 votes
Kristian Walker _Adaptavist_
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
April 10, 2020

Hi Ahmed,

I can confirm that Jira stores Draft workflows under the Inactive tab on the workflows page as described here.

This means that if you navigate to here in your instance then you will see any draft workflows not associated to any projects.

If there are no inactive workflows then this will indicate that you have no inactive draft workflows to be deleted inside of your instance.

If you need to delete a workflow still associated to a project then Jira will not allow this until you associate a new workflow to the project to make the workflow that you want to delete inactive.

I hope this information helps.

Regards,

Kristian

Deleted user April 10, 2020

Hi Kristian,

Draft workflows are workflows copies created in edition mode. They are applicable for active and inactive ones. 

Extract from the link provided : When you edit an active workflow, Jira first creates a draft of it, that you can then modify as you see fit.

Draft mode is also applicable for workflow scheme.

I found a method hasDraftWorkflow() wich returns true for some active workflows in my jira instance.

Thanks

Ahmed

Kristian Walker _Adaptavist_
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
April 10, 2020

Hi Ahmed,

Thank you for your response.

I do not know how the hasDraftWorkflow() method works and would advise for each worklow it returns true for to check if the draft workflows show in the Inactive section of the workflows page.

I believe by default the draft workflows will be given a name such as Copy of <WorkflowName>.

I hope this helps.

Regards,

Kristian

Deleted user April 11, 2020

Hi Kristian,

I found the solution :)

Use workflowManager.getDraftWorkflow(parentWorkflowName) to retrieve draft workflows.

Use workflowManager.deleteDraftWorkflow(parentWorkflowName) to delete them

Regards,

Ahmed

Like # people like this
Kristian Walker _Adaptavist_
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
April 11, 2020

Hi Ahmed,

Thank you for confirming that you found the solution, I will note down this myself for future.

Regards,

Kristian

Fazila Ashraf
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
November 15, 2022

Hi @[deleted]   

Did you find a way to list out all draft workflows in the JIRA instance? Even the ones for which you dont know who is the parent workflow?

ChristopherChilds
Contributor
January 30, 2025
A little late to the party but I think @Fazila Ashraf  This is what you are after:
def workflowManager = ComponentAccessor.getComponent(WorkflowManager)

def
allWorkflows = workflowManager.getWorkflowsIncludingDrafts()

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events