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

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

Hiding a custom field in the issue creation popup

Hello,

I created 1 mandatory custom field.

I want it :

  • to be hidden in the issue screen creation but setted with the value of another field for the project P1
  • not to exist in the issue screen creation for the project P2

I rattached the project P1 to the configuration field CF1 by setting the custom field mandatory and visible.
I rattached the project P2 to the configuration field CF2 by setting the custom field masked.

I added Javascript code to hide the custom field and to set the value. Below is the code for hiding the
custom field :

<script>
var selected_acte_customfield = "customfield_12902";
var actes_customfield = "customfield_12800";
function jqid (id) {
return (!id) ? null : '#' + id.replace(/(:|\.|\[|\]|,)/g, '\\$1');
}

AJS.$(jqid(selected_acte_customfield)).closest('div.field-group').hide();

function manageSAU(context) {
if (typeof context != 'undefined') {
var actes = AJS.$(context).find(jqid(actes_customfield));
var selected_acte = AJS.$(context).find(jqid(selected_acte_customfield));
changeSAU(actes, selected_acte);
} else {
var actes = AJS.$(jqid(actes_customfield));
var selected_acte = AJS.$(jqid(selected_acte_customfield));
changeSAU(actes, selected_acte);
}
}
function changeSAU(actes, selected_acte) {
actes.on( "change", function() {
var selected;
if (actes.length==1) {
selected = actes.find('option:selected').text();
} else {
selected = actes[0].selectedOptions.item(0).innerText;
}
selected_acte.val(selected);
selected_acte.trigger( "change" );
});
}

AJS.toInit(function(){
JIRA.bind(JIRA.Events.NEW_CONTENT_ADDED, function (e,context) { manageSAU(context); });
manageSAU();
});
</script>

 

When I select the project P1 and click the Create Issue button, the field does not appear in the window.

When I select the project P2 and click the Create Issue button, and, inside the window, I select the project P1, the field appears in the window.

How can I do to hide the field when I change project from P2 to P1 ?

Thanks for your interest.

0 answers

Suggest an answer

Log in or Sign up to answer
TAGS
Community showcase
Published in Jira Software

How to create Jira issus from Excel file?

When to use CSV importer When managing your processes in Jira, there are many occasions where you need to create a lot of tasks. Creating them one by one will cost you a lot of time and effort and i...

4,407 views 22 32
Read article

Community Events

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

Find an event

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

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you