Change select list field to read only

Alon Erez
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.
December 12, 2012

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

0 votes
Answer accepted
Sreenivasaraju P
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.
December 12, 2012

You can use script for making any field readonly.

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

fieldname.disabled=true;

Alon Erez
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.
December 12, 2012

This doesn't work for a select list.

Sreenivasaraju P
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.
December 12, 2012

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.
Alon Erez
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.
December 22, 2012

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

Thanks.

1 vote
Nic Brough -Adaptavist-
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
December 12, 2012

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.

Alon Erez
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.
December 12, 2012

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.

0 votes
MuhammadU December 30, 2012

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

Sreenivasaraju P
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.
December 30, 2012

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>

MuhammadU December 31, 2012

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;

Sumant February 26, 2016

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;
0 votes
Andrey Markelov December 12, 2012

You can use https://marketplace.atlassian.com/plugins/ru.mail.jira.plugins.groupeditfiedls and configure editable for reporter only.

Alon Erez
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.
December 12, 2012

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

Alon Erez
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.
December 12, 2012

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.

Andrey Markelov December 12, 2012

Yeah. So, you need to use different screens.

Andrey Markelov December 12, 2012

Next version of plugin I will implement all system fields

Suggest an answer

Log in or Sign up to answer