Missed Team ’24? Catch up on announcements here.

×
Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Configuring Customfield Contexts when you have hundreds of projects

David Yu
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.
January 23, 2024

Update: This seems completely unnecessary in Jira 9.10.X as they modernized the customfield context settings page.

Have you ever had to configure a customfield context to include a new project, but in doing so, you accidentally deselected all existing projects?

Chaos ensues as you scurry to figure out which projects had the field enabled. Unluckily for you, the audit log does not log this event.

The blame falls partly on how tiny the window is for the project picker, and the outdated model of making users hold Control/Command while clicking elements in the list.

Modify_configuration_scheme_context_-_Jira.png

With some javascript magic, we can expand that size 5 window to 25, and make it so users don't have to hold Control/Command. You can try it out by pasting into the browser's development console:

var selectElements = document.getElementsByName('projects');
var selectElement = selectElements[0];

if (selectElement && selectElement.size == 5) {
selectElement.size = 25;
}

 This next one will ensure items don't get deselected

$('select[multiple] option').mousedown(function(e) {
e.preventDefault();
$(this).prop('selected', !$(this).prop('selected'));
return false;
});

If you like what you see so far, the next step involves having Scriptrunner's Script Fragments feature load these scripts on the Manage Custom Fields screens. The best configuration I've found so far is atl.admin but maybe there's a better one that's less broad in case there's any impact to other pages. This is the final script for ScriptRunner that I use:

document.addEventListener('DOMContentLoaded', function() {
var selectElements = document.getElementsByName('projects');
var selectElement = selectElements[0];

if (selectElement && selectElement.size == 5) {
selectElement.size = 25;
}

$('select[multiple] option').mousedown(function(e) {
e.preventDefault();
$(this).prop('selected', !$(this).prop('selected'));
return false;
});
});

I'm not great with javascript...most of these was grabbed via google so please let me know if there are improvements to be made.

Edit 1: Chrome does a weird scrollback thing when clicking on items. Found a solution for that here.

0 comments

Comment

Log in or Sign up to comment
TAGS
AUG Leaders

Atlassian Community Events