Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
Celebration

Earn badges and make progress

You're on your way to the next level! Join the Kudos program to earn points and save your progress.

Deleted user Avatar
Deleted user

Level 1: Seed

25 / 150 points

Next: Root

Avatar

1 badge earned

Collect

Participate in fun challenges

Challenges come and go, but your rewards stay with you. Do more to earn more!

Challenges
Coins

Gift kudos to your peers

What goes around comes around! Share the love by gifting kudos to your peers.

Recognition
Ribbon

Rise up in the ranks

Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!

Leaderboard

Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
4,551,769
Community Members
 
Community Events
184
Community Groups

Can't return workflow scheme name from a project

Hi there,

I'm trying to make a quick report based on an idea I saw on the Isos Technology blog (https://blog.isostech.com/atlassian/finding-where-issue-types-are-used-the-quick-way, worth a read).

I want to output this project data where the project contains a specific issue type:

Issue Name, Project Key, Issue Scheme, Workflow Scheme, IssueType Screen Scheme.

The variable "iwf" (Workflow Scheme) is returning a map, but I'm failing to get the value for the 'name' key from it.

Here's the code:

import com.atlassian.jira.component.ComponentAccessor

//replace with your issue type name
def issueTypeName = "Idea"

def schemeManager = ComponentAccessor.issueTypeScreenSchemeManager
def issueTypeSchemeManager = ComponentAccessor.issueTypeSchemeManager
def wfSchemeManager = ComponentAccessor.workflowSchemeManager
def sb = new StringBuffer()
//iterate over all projects in instance
ComponentAccessor.getProjectManager().getProjectObjects().each{ project->
//iterate over issue types for this project
project.getIssueTypes().each{ issuetype->
def thisIssueTypeName = issuetype.name.toString()
//check if correct issue type
if(thisIssueTypeName == issueTypeName) {
//get issue type screen scheme name for project
def iss = schemeManager.getIssueTypeScreenScheme(project).getName()
def its = issueTypeSchemeManager.getConfigScheme(project).getName()

// HERE IS THE PROBLEM:
def iwf = wfSchemeManager.getWorkflowScheme(project)
//def iwfn = iwf.collect {it.value.name} // nope

//output project and issue type screen scheme we found
sb.append("${issueTypeName}|${project.key}|${its}|${iwf}|${iss}\n")
}
}
}
log.info "Issue_Name|Project_Key|Issue_Scheme|Workflow_Scheme|IssueType_Screen_Scheme"
log.info sb.toString()

 

Example output:

Issue_Name|Project_Key|Issue_Scheme|Workflow_Scheme|IssueType_Screen_Scheme 

Idea|DPP|FSG Product Planning Issue Type Scheme|[name:FSG Product Planning Workflow Scheme, description:, id:11705]|FSG Product Planning Issue Type Screen Scheme

Any reference to 'name' throws a null by any means I've tried so far.

How do I pull "FSG Product Planning Workflow Scheme" out of that map?

Or, am I looking for that string in the wrong place to begin with?

Thanks,

April

1 answer

1 accepted

0 votes
Answer accepted
Peter-Dave Sheehan
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
Jul 05, 2021

If you are just trying to get the workflow name for a specific issue type, you can get that directly from the workflowSchemeManager

wfSchemeManager.getWorkflowName(project, issuetype.id)

Otherwise, to get the workflowScheme name for a project, you should be able to get that directly from the scheme object:

wfSchemeManager.getWorkflowScheme(project).name

Peter, you are going to laugh at this one...

First thing I tried was ".name" but got the null error.

I just tried adding Groovy safe navigation:

wfSchemeManager.getWorkflowScheme(project)?.name

It turns out that if a project has the Jira default workflow scheme, there's no name to get. Thought it would have a name attribute like "Default...."

Other default schemes do have names, e.g. "Default Issue Type Scheme" but clearly that is not always true, so I guess safe nav is the way to go for querying schemes.

Thanks for your help. Thought I was losing it!

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events