Is there any way to hide fields in bulk when editing field configurations?

We have a good number of custom fields.  When I make a new field configuration all of these fields are visible by default, which means, if I were to give someone project admin rights, they would see anything not hidden, and hiding fields from the configuration is a PAINFULLY TEDIOUS practice - scroll to field, click hide, wait for refresh, scroll, etc....

There must be an easier way...

6 answers

This widget could not be displayed.

Robert,

I have ran into the same problem. When in the issue navigator, my users don't want to see all the CFs in JIRA they only want to see the CFs associated to their project. This is only possible by hiding the CFs in the field configuration associated with that project. 

I created a custom groovy script that can be ran from the ScriptRunner Script Console. You define the the Project Key and the field names that you want to be visable. then run it and it will hide all the CFs in that field configuration except for the ones that you defined to be visable.

I am trying to create a script to auto hide a CF in all field configurations when it is created but that is proving more dificult then I thought. I hope this helps with your problem. 

import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.fields.FieldManager;
import com.atlassian.jira.issue.fields.CustomField;
import com.atlassian.jira.issue.fields.layout.field.FieldLayoutManager;
import com.atlassian.jira.issue.fields.layout.field.FieldLayoutItem;
import com.atlassian.jira.issue.fields.layout.field.EditableFieldLayout;
import com.atlassian.jira.project.Project

//*** Get Needed Managers ***
FieldManager fieldManager = ComponentAccessor.getFieldManager();
FieldLayoutManager layoutManager = ComponentAccessor.getComponent(FieldLayoutManager)

//*** Initialize Variables ***
String result = "Done";
String projKey = "KEY"; //JIRA project Key
String[] usedFields = [
"CF1", //Custom Field Name
"CF2" //Custom Field Name
] as String[]

//Only look in the specified project
Project nextProject = ComponentAccessor.getProjectManager().getProjectObjByKey(projKey)

//Get all the Unique Field Layouts related to the project
def fLayouts = layoutManager.getUniqueFieldLayouts(nextProject)

//Loop throught the layouts
for (layout in fLayouts){

//Check if the layout name is not Null
if (layout.getName() != null){

//Get the ID of the layout
def layoutId = layout.getId();

//Loop through all the layout items (Custom Fields)
for (cf in layout.getFieldLayoutItems()){

//Check if Custom Field
boolean isCF = fieldManager.isCustomField(cf.getOrderableField().getId());
if (isCF == true){

//*** Lookup Field Layout ***
EditableFieldLayout editableLayout = layoutManager.getEditableFieldLayout(layoutId);

//*** Lookup Custom Field ***
CustomField field = fieldManager.getCustomField(cf.getOrderableField().getId());
FieldLayoutItem item = editableLayout.getFieldLayoutItem(field);

//Set visablilty of field
if usedFields.contains(cf.getOrderableField().getName())){

//If item is hidden make it visible
if(item.isHidden() == true){
//*** Update Field Visability ***
editableLayout.show(item);
layoutManager.storeEditableFieldLayout(editableLayout)

}
}
else {
//*** Update Field Visability ***
editableLayout.hide(item);
layoutManager.storeEditableFieldLayout(editableLayout)
}
}

}
}
}
return result;

This is a helpful starting point, thank you!

import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.fields.FieldManager;
import com.atlassian.jira.issue.fields.CustomField;
import com.atlassian.jira.issue.fields.layout.field.FieldLayoutManager;
import com.atlassian.jira.issue.fields.layout.field.FieldLayoutItem;
import com.atlassian.jira.issue.fields.layout.field.EditableFieldLayout;
import com.atlassian.jira.project.Project
import org.apache.log4j.Level

log.setLevel(Level.INFO)

//*** Get Needed Managers ***
FieldManager fieldManager = ComponentAccessor.getFieldManager();
FieldLayoutManager layoutManager = ComponentAccessor.getComponent(FieldLayoutManager)

//*** Initialize Variables ***
String result = "Done";
String projKey = "Key"; //JIRA project Key
String[] usedFields = [
"Field 1",
"Field 2"
] as String[]

Project p = ComponentAccessor.getProjectManager().getProjectObjByKey(projKey)

def fieldLayouts = layoutManager.getUniqueFieldLayouts(p)

for (layout in fieldLayouts){
if (layout.getName() != null){
log.info "LAYOUT: ${layout.name}"
def layoutId = layout.getId();

EditableFieldLayout editableLayout = layoutManager.getEditableFieldLayout(layoutId);

for (fieldLayoutItem in layout.getFieldLayoutItems()){

//We won't touch system fields
boolean isCF = fieldManager.isCustomField(fieldLayoutItem.getOrderableField().getId());
if (isCF == true){
CustomField field = fieldManager.getCustomField(fieldLayoutItem.getOrderableField().getId());
FieldLayoutItem item = editableLayout.getFieldLayoutItem(field);

if (usedFields.contains(fieldLayoutItem.getOrderableField().getName())){
if(item.isHidden() == true){
editableLayout.show(item);
}
} else {
editableLayout.hide(item);
}
}
}
layoutManager.storeEditableFieldLayout(editableLayout)
}
}
return result;

 I hope you don't mind, Kevin; I did a little light editing on your code to make it more readable and more efficient. You don't need to save after every update; you can iterate over the fields and hide the unneeded ones and just save it once. In a system with hundreds of fields, your code takes hours to run. In my test environment, which has 800+ custom fields, the original code is heading into hour three of runtime against a field configuration scheme that has six field configurations (meaning that it's saving field configurations over 5000 times). The revised version here completed successfully in under a minute.

This widget could not be displayed.

I have found a simple workaround that works OK given the poor UX around the screen. It effectively lets me quickly scroll down the page of fields and quickly disable fields that you don't want.

  1. Navigate to the Field Configuration you want to modify.
  2. Start scrolling down the list of fields and middle click the "Hide" link for fields you want to hide. This opens up a new window with that link (in Chrome) but has the effect of you clicking the link without the annoying refresh issue.
  3. You can ignore the opened tabs and close them all later once you are done. I use the "Close tabs to the right" feature by right clicking on the tab in Chrome.

 

By the way, the real nuisance and the reason why I need to hide the fields is because it causes a lot of clutter in the Bulk Edit screen. The solutions proposed around updating the Screen configuration don't affect the Bulk Edit screen.

Thanks Luke.  It works a lot better than anything Atlassian has provided...

This widget could not be displayed.

Hi Robert,

Have you tried copying an existing Field Config? This should reduce the effort involved in hiding fields if another Field Config already has those fields hidden

None of my configuration have them hidden. Until now I have no project admins, so it wasn't an issue. I never looked at that screen.

Unfortunately this is also only a temporary measure, as any time a new field is added to the system it becomes visible.

This widget could not be displayed.

Unfortunately, I'm coming to the conclusion that Atlassian believe custom fields are evil, and should be avoided at all costs. 

I come to this conclusion because there is absolutely ZERO SUPPORT OR SYMPATHY FROM ATLASSIAN for users whose systems have either intentionally or accidentally amassed a large collection of custom fields.  JIRA just isn't equipped to deal with it.

 

Richard I agree -  super tedious and I have spent a good 30mins trying to find informaiton on how to:

  • avoid new fields from automatically showing in a field configuration (it doesnt matter if I associate it to only one project, the field displays on existing AND new field configurations....WHYYYYYYYYYYYYYYYYY
  • even if the custom field is assigned to a project/issue type this is not a option when creating so the field shows in all field configs....also when you do restrict to a project/issue type it still shows for all field configs. 
  • easily (i.e. bulk) remove fields that should not be associated to a field configuration......as others have said 
  • keep field configurations from automatically being generated when you create a project as well as remove field configuration when you delete a project.

Guess Atlassian missed the opportunity to make the system more flexible this way - in order to set up multiple projects and use JIRA across various departments there will be multiple custom fields needed! This makes it a royal pain to administer - I have to go through 300+ fields and deselect those not used in a project...FOR ALL MY PROJECTS...pretty ridiculous. 

Anyone else found anything useful for this? 

This widget could not be displayed.

I think the key is in using the screen schemes correctly. Make sure you have appropriate screens created for your projects and add only required fields on those screens.

When a new custom field is added, it will appear in a project only if you add the field into the screens used by that project.

It doesn't matter how the screens are configured, every bloody field in the system still appears unless explicitly hidden.

OK, for example, I created a project for one team that has something like 20 custom fields that were configured for use ONLY with that project. When I go to the project summary for other projects and look at the field configs, those fields still show. Why can't Jira only show the fields applicable to the project?

Fields show in the field config but they won't appear when you create/edit an issue. If the fields are not on the screen and the fields are not associated with the project, they won't appear even if it is there in the field config screen. In your case, the 20 custom fields are configured for one project and they won't appear in the other projects even if they are using a field config scheme that has it.

The problem here is I want to give Project Admin rights to people, but don't want them snooping. Unfortunately Atlassian allows project admins to see FAR too much.

I don't want to expose EVERYTHING. There are going to be times when I need to give someone Project Admin access so they can create their own components, but I don't want them seeing certain things.

This widget could not be displayed.

Hi @Robert Horan!

It's probably too late to reply to you, but here's what I got anyway. New admins might still be running into this post (like I did).

I've set up a JMeter thread to workaround it. There are a few issues to deal with (like extracting the atl_token from the response header, setting up the controllers and the counting variable) but it worked like a charm!

This time I made an "Empty Field Configuration" which I'll clone for new projects.

I also use JMeter to reorder Statuses.

 

Cheers

Hello Rodrigo Carvalho,

so did you find a solution to hide fields in the bulk select?

If so could you be so kind and explain it?

Thanks

Suggest an answer

Log in or Sign up to answer
Atlassian Summit 2018

Meet the community IRL

Atlassian Summit is an excellent opportunity for in-person support, training, and networking.

Learn more
Community showcase
Posted Wednesday in New to Jira

Are you planning to trial, or are currently trialling Jira Software? - We want to talk to you!

Hello! I'm Rayen, a product manager at Atlassian. My team and I are working hard to improve the trial experience for Jira Software Cloud. We are interested in   talking to 20 people planning t...

196 views 3 0
Join discussion

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you