A scripted way, to get all edit screens.

Milan B April 11, 2023

My goal is: I want to get all screens, that are in use as "Edit screens". 

Since it would be a lot of clicking around, to go through all projects, into the project settings, on the screens section, and check all schemes, and since I want to get a bit practice, I want to write a script to do the job. 

So far I can read all projects, I can read the Issue type screen scheme for each project, and the Screen schemes, that are configured for each Issue type within the Issue type screen scheme. But I cannot read the Edit screen, that is configured in a Screen scheme. 

Here is the code I have so far:

{code}

import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.project.ProjectManager
import com.atlassian.jira.project.Project
import com.atlassian.jira.issue.operation.IssueOperationImpl

List<Project> probs = ComponentAccessor.getProjectManager().projectObjects

probs.each{ prob ->
    def itss = ComponentAccessor.getIssueTypeScreenSchemeManager().getIssueTypeScreenScheme(prob)
    log.warn("Issue type screen scheme entities for: ${itss.getName()}")

    log.warn("Entities:")
    itss.getEntities().each{ entity ->
        log.warn("${entity.getIssueType()?.getName()} - ${entity.getFieldScreenScheme().getName()}")
    }

}

{code}

What I found :

When I have a Screen scheme, and I want to read the Edit screen, there is a method: FieldScreen getFieldScreen(IssueOperation issueOperation ) 

But I don't know how to provide that parameter "IssueOperation". It's not a string or an enum, it's an Object, I can create such an Object, but it's not giving the expected result.

E.g.:

itss.getEntities()[0].getFieldScreenScheme().getFieldScreen(new IssueOperationImpl("Edit Issue",""))
Is giving me the Create screen. 

 

I'm afraid, this is very specific, but any help is much appreciated. 

 

1 answer

1 accepted

1 vote
Answer accepted
Florian Bonniec
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, 2023

Hi @Milan B 

I do not have much time to investigate to make it work with IssueOperationImpl BUT below a script that go through all Screen Scheme and return screen in Edit Operation.

 

import com.atlassian.jira.component.ComponentAccessor

def fieldScreenManager = ComponentAccessor.getFieldScreenManager()
def fieldScreenSchemeManager = ComponentAccessor.getFieldScreenSchemeManager()
fieldScreenSchemeManager.getFieldScreenSchemes().each{ screenScheme ->
    screenScheme.getFieldScreenSchemeItems().each{
        if(it.getIssueOperationName().toString() in ['admin.issue.operations.edit']){
            log.error it.getFieldScreen().getName()
        }
    }
}
Milan B April 11, 2023

Thank you, it works perfect :-)

Suggest an answer

Log in or Sign up to answer