Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

How to get issue type type object?

arama mihai
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
April 20, 2021

Hello, 

I have the following piece of code: 

 

def firstProjectKey = 'ABC'
def getFirstProject = projectManager.getProjectByCurrentKeyIgnoreCase(firstProjectKey)

def firstProjectIssueTypesList2 = itsm.getIssueTypesForProject(getFirstProject)

def issueTypeScreenSchemeManager = ComponentAccessor.getIssueTypeScreenSchemeManager()

for (issueType in firstProjectIssueTypesList2){
log.warn(issueType)
def fieldScreenScheme = issueTypeScreenSchemeFirstProject.getEffectiveFieldScreenScheme(issueType)
}

 

I run this in the console and i get:

groovy.lang.MissingMethodException: No signature of method: java.lang.String.getEffectiveFieldScreenScheme() is applicable for argument types: (com.atlassian.jira.issue.issuetype.IssueTypeImpl) values: [IssueConstantImpl[[GenericEntity:IssueType][sequence,null][name,Project][iconurl,/secure/viewavatar?size=xsmall&avatarId=12315&avatarType=issuetype][description,Issue Type for GLC][style,null][id,10403][avatar,12315]]]
at Script1787.run(Script1787.groovy:204)

 

What is the format that it wants? I saw in:  https://docs.atlassian.com/software/jira/docs/api/7.0.0/com/atlassian/jira/issue/issuetype/class-use/IssueType.html that it expects a "issue type type" .. but how does that look, where to get it from?

 

Thank you!

 

1 answer

1 accepted

3 votes
Answer accepted
Ram Kumar Aravindakshan _Adaptavist_
Community Champion
April 20, 2021

Hi @arama mihai,

If you want to get the Issue Type using the ScriptRunner console, you could try something like this:-

import com.atlassian.jira.component.ComponentAccessor

def issueManager = ComponentAccessor.issueManager
def issue = issueManager.getIssueByCurrentKey("MOCK-44")
log.warn "====>>> ${issue.issueType.name}"

 Please note, this sample code is not 100% exact to your environment. Hence, you will need to make the required modifications.

Below is a print screen of the console for your reference:-

console1.png

I hope this helps to solve your question :)

 

Thank you and Kind Regards,

Ram

arama mihai
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
April 20, 2021

Hi @Ram Kumar Aravindakshan _Adaptavist_ ,

 

Thank you very much for your reply! I am, however, trying to get the screen scheme out of a issue type screen scheme, and I am not using any issues. I used :

def issueTypeScreenSchemeManager = ComponentAccessor.getIssueTypeScreenSchemeManager()
def issueTypeScreenSchemeFirstProject = issueTypeScreenSchemeManager.getIssueTypeScreenScheme(getFirstProject).name

to get the project's issue type screen scheme.

Now, I want to get the screen schemes that are part of this issue type screen scheme, and their association to each issue type.

Would this be possible?

 

Thank you!

Ram Kumar Aravindakshan _Adaptavist_
Community Champion
April 20, 2021

Hi @arama mihai

For your requirement, you could try something like this:-

import com.atlassian.jira.component.ComponentAccessor

def schemeManager = ComponentAccessor.issueTypeScreenSchemeManager
def projectManager = ComponentAccessor.projectManager
def projectObjects = projectManager.projectObjects
def builder = new StringBuilder()

projectObjects.each{

it.issueTypes.each{ issuetype->

if(it.key == "MOCK") {

def issueTypeScreenScheme = schemeManager.getIssueTypeScreenScheme(it)

builder.append("\nProject Name: ${it.name}, \t Issue Type: ${issuetype.name},\t Issue Type Screen Scheme: ${issueTypeScreenScheme.name}\n")
}

}
}
log.warn builder.toString()

Please note, this sample code is not 100% exact to your environment. Hence, you will need to make the required modifications.

Below is a print screen of the code along with the output:-

console2.png

I hope this helps to solve your question :)

 

Thank you and Kind Regards,

Ram

Like arama mihai likes this

Suggest an answer

Log in or Sign up to answer