Just a heads up: On March 24, 2025, starting at 4:30pm CDT / 19:30 UTC, the site will be undergoing scheduled maintenance for a few hours. During this time, the site might be unavailable for a short while. Thanks for your patience.
×I can't say I 100% understood your post but I think you can start with the below code.
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.CustomFieldManager
import com.atlassian.jira.issue.fields.CustomField
import com.atlassian.jira.issue.fields.screen.FieldScreen
import com.atlassian.jira.issue.fields.screen.FieldScreenTab
import com.atlassian.jira.issue.fields.screen.FieldScreenScheme
import com.atlassian.jira.issue.fields.screen.FieldScreenSchemeManager
import com.atlassian.jira.util.ErrorCollection
CustomFieldManager customFieldManager = ComponentAccessor.getCustomFieldManager()
CustomField customField = // your custom field to add to the screen
FieldScreenSchemeManager fieldScreenSchemeManager = ComponentAccessor.getComponent(FieldScreenSchemeManager.class)
FieldScreen fieldScreen = fieldScreenSchemeManager.getFieldScreen(FieldScreen.DEFAULT_SCREEN_ID)
// Get field screen tab (assuming you have only one tab or add to the default tab)
FieldScreenTab fieldScreenTab = fieldScreen.getTab(0)
// Add custom field to field screen tab
fieldScreenTab.addFieldScreenLayoutItem(customField.getId())
// Update field screen
fieldScreenSchemeManager.updateFieldScreen(fieldScreen)
List<FieldScreenScheme> fieldScreenSchemes = fieldScreenSchemeManager.getFieldScreenSchemes()
// add custom field to each scheme
for (FieldScreenScheme scheme : fieldScreenSchemes) {
scheme.addFieldScreen(fieldScreen)
ErrorCollection errorCollection = fieldScreenSchemeManager.updateFieldScreenScheme(scheme)
if (errorCollection.hasAnyErrors()) {
log.error("Error adding custom field to field screen scheme: " + errorCollection.getErrorMessages())
}
}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thanks for your message, why do you think it is not the right code?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hello @Tuncay Senturk ,
Please put the code in script console of scriptrunner. It will show you the errors.
We are using Jira 9.4.7 and i hope you're using the same so if you can refer below Java APIs, you won't find the methods (you've used in your code) in the article:
The methods are available in FieldScreenManager i suppose:
I would be glad too if i am wrong in here :) but just got this observation.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Yes, you are right, this is quite old version I suppose. They (FieldScreenSchemeManager) need to be changed (to FieldScreenManager)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Atlassian Government Cloud has achieved FedRAMP Authorization at the Moderate level! Join our webinar to learn how you can accelerate mission success and move work forward faster in cloud, all while ensuring your critical data is secure.
Register Now
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.