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,559,686
Community Members
 
Community Events
185
Community Groups

Jira - groovy - get custom fields from screens of project

Hi,

I need get list of custom fields which I have on all of screens on a project.

Have you any advice how can I get this by groovy script?

 

Thanks

 

 

 

2 answers

Hi Lukas,

I ended up in the exactly same situation as you and solved it by:

 

//imports ad lib...

Set<String> getFieldsOnScreen(FieldScreenScheme fieldScreenScheme, IssueOperation issueOperation) {
CustomFieldManager customFieldManager = ComponentAccessor.getComponent(CustomFieldManager)
Set<String> result = new HashSet<String>()

FieldScreen fieldScreen = fieldScreenScheme.getFieldScreen(issueOperation)
fieldScreen.getTabs().each{FieldScreenTab fieldScreenTab ->
fieldScreenTab.getFieldScreenLayoutItems().each{FieldScreenLayoutItem fieldScreenLayoutItem ->
String fieldId = fieldScreenLayoutItem.getFieldId()
// I am only interested in custom fields - change appropriately
if (fieldId.startsWith("customfield")) {
CustomField customField = customFieldManager.getCustomFieldObject(fieldId)
result.add(customField.getName())
}
}
}

return result
}

Set<String> getFieldsOnScreens(FieldScreenScheme fieldScreenScheme) {
// I am only interested in Edit and View screens - change appropriately
return getFieldsOnScreen(fieldScreenScheme, IssueOperations.EDIT_ISSUE_OPERATION) + getFieldsOnScreen(fieldScreenScheme, IssueOperations.VIEW_ISSUE_OPERATION)
}

IssueTypeScreenSchemeManager issueTypeScreenSchemeManager = ComponentAccessor.getIssueTypeScreenSchemeManager()

IssueTypeScreenScheme issueTypeScreenScheme = issueTypeScreenSchemeManager.getIssueTypeScreenScheme(<My Project>)
FieldScreenScheme fieldScreenScheme = issueTypeScreenScheme.getEffectiveFieldScreenScheme(<My IssueType>)

return getFieldsOnScreens(fieldScreenScheme)

Hi Sune,

the easiest way I saw on this site.

By the way, it does not take care of the "technical" fields hidden in transition screens nor postFunctions.

 

+1 anyway.

Hi Lukas,

I can show you how to get a list of all fields on the screens for a given issue if that helps.

//Sune

Adam Sasin
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
Mar 09, 2023

Would you like to share with us this knowledge?

Adam Sasin
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
Mar 09, 2023

im asking because i don't know how to get what custom field i have for view screen for specific issue type by groovy

Hi Adam,

The code I pasted above should do it.

//Sune

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events