Change select list field to read only

Hi,

I’ve a select list field that I want to change to read only after the issue was created. I still want to show it in all screens, but to prevent the users from changing the value.

How can this be done ?

Thanks,

Alon

4 answers

1 accepted

You can use script for making any field readonly.

var fieldname= document.getElementById('customfield_xxxx');

fieldname.disabled=true;

This doesn't work for a select list.

It will work for all custom fields, we are using it. It works properly.

You use following code also to enable the field while submitting other wise custom field value will reset to null
var editSubmit=document.getElementById('edit-issue-submit');
if(null!=editSubmit)
{
editSubmit.onclick=function()
{
fieldname.disabled=false;
}
}
If you can let us know the problem you are facing we can help you.

We ended up using this is the base for our script.

Thanks.

1 votes

You don't need any plugins.

Look at your "screen scheme", in there, you'll find you can tell Jira to use different "screens" for Create, Edit and View. A screen is a list of fields to present to the user. Generally, most schemes use the same screen for everything, to keep it simple, but you can change this.

For your case, I would have two screens:

Screen 1: Has your select list on it somewhere. Use this for View and Create

Screen 2: Does NOT have your select list on it. Use this for Edit

You'll be able to populate a value when creating the issue, and then not change it later. One other thing to consider - workflows may have "transition screens" - you'll want to check if those screens have your field.

Thanks, I'm aware of this option.

However I want the users to see the value in the field in all screens. so removing it from other screens is not an option in this case. and this field also appears in transition screens.

Thanks, but this is only for version 5.2, we are using 5.0.7.

Thanks, I didn’t see this.

Looks like a useful plugin.

However I failed to mention that the field I'm talking about is the version list, so I don’t see how I can use this plugin in this case.

Yeah. So, you need to use different screens.

Next version of plugin I will implement all system fields

@prathighantam can you please eloborate in detail? Where to put the javascript code and how ?

You can put the java script on any field of your screen . In the field config of your project/issue type you add this script.

<script>

var editSubmit=document.getElementById('edit-issue-submit');

var fieldname= document.getElementById('customfield_xxxx');

fieldname.disabled=true;

if(null!=editSubmit)

{

editSubmit.onclick=function()

{

fieldname.disabled=false;

}

}

</script>

Nope, not working ... I am using JIRA 5.2.2.

&lt;script&gt;
var editSubmit=document.getElementById('edit-issue-submit');
var cfc_10404= document.getElementById('customfield_10404');
cfc_10404.disabled=true;
if(null!=editSubmit)
{
editSubmit.onclick=function()
{
cfc_10404.disabled=false;
}
}
&lt;/script&gt;

Use the below snippet to enable the custom field, before the issue is created. This is using the native AJS.

&lt;script type="text/javascript"&gt;
AJS.$( document ).ready(function() {
AJS.$("#issue-create-submit").click(function(){
AJS.$("#customfield_XXXXX").attr("disabled",false);
});
});
&lt;/script&gt;

Suggest an answer

Log in or Join to answer
Community showcase
Sarah Schuster
Posted Jan 29, 2018 in Jira

What are common themes you've seen across successful & failed Jira Software implementations?

Hey everyone! My name is Sarah Schuster, and I'm a Customer Success Manager in Atlassian specializing in Jira Software Cloud. Over the next few weeks I will be posting discussion topics (8 total) to ...

3,146 views 13 19
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
Atlassian Team Tour

Join us on the Team Tour

We're bringing product updates and pro tips on teamwork to ten cities around the world.

Save your spot