Set particular custom field read only

Liwei E October 27, 2013

Hi There,

I am currently administrating a JIRA project. and i have added several cutome fields. and now there is a require for restricting editing on certain fields during the lifecycle of an issue, or in another word, once some of the custom fields have been created, they should be disabled from editing for all users.

I am thinking there would be two way of doing these,

  • make the field read only, but seems the read-only text field is not design for this scenario, any other suggestions?
  • do some user permission setting, but seems there is no permission setting for view only.

Could you guys suggest a solution or workaround doing this?

Thanks in advance.

Liwei

8 answers

1 accepted

21 votes
Answer accepted
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.
October 29, 2013

Hang on, there's a whole lot of totally unneccesary code being thrown around here.

Peter's original answer is correct, as is Henning's follow up.

Put the field on the CREATE and VIEW screens. Do not put it on the EDIT screen.

The user can then add data to the field when it is created. They will not be able to change it again. Click-to-edit is disabled for fields that are not on the edit screen. If you need to change it later in the process, you can put it on a transition screen.

Liwei E November 5, 2013

But the fields still needs to be viewed during the flow, and with my understanding of JIRA, if the certain fields can be viewed, it also means the fields can be modified.

Like # people like this
Henning Tietgens
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.
November 5, 2013

What do you mean with "during the flow"? If a field is editable on the view screen depends on if the field is on the edit screen.

If you add the field to a transition screen it's editable in this transition (independend from the view/edit editability). A transition could be "protected" by a condition.

Peter Van de Voorde
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
November 5, 2013

Hi Liwei,

If the fields are only viewable on the view screen (the screen associated with the view issue action in your Screen Scheme) and not on any other screen (except the screen associated with the Create issue action in your screen scheme) they can not be edited.

Best regards,

Peter

Nabil Sayegh
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.
March 9, 2015

The field will still be editable in batch edit.

Like Flash_Sheridan likes this
Morgan Thunder May 27, 2016

I think the issue with this solution is that it means the fields are never editable. Is there a way to have an edit screen but make it no longer accessible after a certain point in a workflow?

Like # people like this
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.
May 27, 2016

No. 

You can use workflow properties to block all edits when in a status, but not field edits.  The way to handle what you're asking for is to move edit into the workflow, as mentioned above.

Morgan Thunder May 27, 2016

Thanks for answering. I'm sorry - I'm not clear on what you mean by 'move edit into the workflow'. did read over the 'above' a few times! I want everything to be editable at any time the ticket is viewed, right up until the issue is transitioned to 'archive' status - whereupon, I guess ideally I would like the 'Edit' option to simply disappear when viewing the ticket.

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.
May 27, 2016

You can edit a field in two ways basically. 

If you have it on the "edit" screen, then it's editable when editing the issue or by clicking in the view screen, and in places that support edit functions.  If you remove it from there, it's effectively read-only (barring place 2)

If you put a field on a transition screen, then the user can change the content during a transition.  That's "move edit into the workflow".  Transitions are locked to status and can be controlled with conditions and validators.

If you want to remove "edit" for all fields of an issue because it's in a status, then the best option is to use workflow properties - set jira.editable = false on the "archive" status in your workflow.  (Have a look at the default uneditable JIRA workflow - it has the flag set on "closed")

Like # people like this
Morgan Thunder May 27, 2016

Hi Nic - thanks - the last thing you said sounds perfect for what I want to do. Unfortunately I can't view the properties of that JIRA workflow's 'closed' status precisely because it's uneditable.I tried putting jira.editable in the property key and 'false' for property value but I get Key starts with 'jira.' but is not known to JIRA...

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.
May 27, 2016

Ah, sorry, I usually take a copy of it, which you can then edit.

But it's also on https://confluence.atlassian.com/jira/workflow-properties-189949.html

Morgan Thunder May 27, 2016

Brilliant - it's jira.issue.editable - thanks a million!

Jozef Vandenmooter March 21, 2018

Right: the field can still be changed during a Bulk Edit. Is there any way to prevent that? I used SR to make a field Read-only, but even that does not prevent a user who has the bulk update permission from making changes to this field!

Like Flash_Sheridan likes this
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.
March 21, 2018

No, Behaviours can't prevent bulk-edit.

Jozef Vandenmooter March 21, 2018

Wow - that's disappointing. Guess we'll have to hand out that Bulk Edit permission more sparingly...

Thanks,

Jozef

Like Flash_Sheridan likes this
Heather Rimmey April 6, 2018

The JIRA Field Security Plugin prevents bulk updates, but it brings lots of other issues. I'm ready to give up on it because its not worth the trouble.

yomost June 3, 2019

The "new Jira issue view" does away with the distinction between the Edit and View screens, so unfortunately this answer is no longer relevant.

As far as I can see, there is no longer a way to make a custom field read only.

Like Ryan Cabanas likes this
Brook Warner July 3, 2019

Damn. 

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.
July 3, 2019

The answers remain valid for Server, and Cloud users on Classic projects.  Next-gen is very different, and is expected to re-implement issue security soon, at which point the answers will become right for it again.

Like Aamir Saleem Sani likes this
Wayne Wagler October 18, 2019

We're on Jira Cloud and our projects were created before Next-gen rolled out, thus I assume we are "Classic".

We have a few screens in use, but can't see whether they are Create, Edit or View.  Most screens I deal with have names like "default issue" or "workflow".  If I delete a field from these screens then I can no longer see it.  

I wonder if the implication here is configuring things differently than now, to allow read only custom fields.  Please advise of the steps I'll need to do.  I've read these posts, but can't seem to connect the dots.  

5 votes
Peter Van de Voorde
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
October 27, 2013

Hi Liwei,

If you only add those field on the issue create screen and don't add those fields to the edit screen in or any screens you use during your workflow they should not be editable after doing an issue creation.

Best regards,

Peter

Liwei E October 29, 2013

Thanks Peter.

But if i create an isolated edit screen or view screen, the fields would be viewed during the workflow lifecycle.

I would really like the fields to be viewed and also non-editable.

Like # people like this
2 votes
Henning Tietgens
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.
October 27, 2013

Besides using a plugin the normal way to archive this is to remove the field from the edit screen and add a transition to the corresponding workflow with a transition screen which contains the field. Access to the transition can be controlled through workflow conditions.

Henning

Liwei E October 29, 2013

Thanks Henning~~ i think the transition control is a good idea, but the default tranisiton conditions provided by JIRA is really limited. But i will try your advices.

Like Flash_Sheridan likes this
2 votes
AlaA
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.
October 27, 2013

Hey Liwei,

I think that should be possible using Behavious plugin, as it allows you to make certain fields to be read-only.

You can download the plugin here:

https://marketplace.atlassian.com/plugins/com.onresolve.jira.plugin.Behaviours

Similar discussion was in the following Answers:

https://answers.atlassian.com/questions/113437/how-to-set-some-fields-as-read-only-after-submit-an-issue

I hope that helps.

Cheers,

Liwei E October 29, 2013

Cheers~~Plugins, i love it. but i am not the system admin, and current there is no plan for inviting any plugins in our company JIRA support team

AlaA
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.
November 5, 2013

I'm sorry to hear that.

Let's wait and check if there are any users who can suggest some better workarounds which might work on your side.

Cheers. :)

Flash_Sheridan December 13, 2018

“This app has been archived”

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 13, 2018

Behaviours became part of Scriptrunner several years ago.

Like Martin Boehme likes this
1 vote
sushanta January 17, 2019

Hi Team,
We have a requirement to make editable only 2 custom filed from edit screen out of 30 for a specific group only i.e project developer role can edit 2 fields only.Is it possible using  Behaviour (Adaptavist script runner) ?
Regards,
Sushanta

0 votes
RambanamP
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.
October 29, 2013

you can hide/show field to specific group by using following scritp, chenage custom field id, group name as per your requirement

<script type="text/javascript">  
jQuery(document).ready(function($) {
	JIRA.bind(JIRA.Events.NEW_CONTENT_ADDED, function (e,context) {	
		hideFieldForGroup();    
	});
		hideFieldForGroup();
function hideFieldForGroup(){
        var user=getCurrentUserName();		
		var statusText=$('#status-val').text();	
		var status=$.trim(statusText);
		if(isUserInGroup(user,'Developers') && status=='In Progress'){			
			$("#customfield_10571").closest('div.field-group').hide();
		}else if(isUserInGroup(user,'Users') && status=='Open') {
			AJS.$("#customfield_10571").closest('div.field-group').show();
		}

}
function getCurrentUserName()
{
var user;
     AJS.$.ajax({
        url: "/rest/gadget/1.0/currentUser",
        type: 'get',
        dataType: 'json',
        async: false,
        success: function(data) {
            user = data.username;
        }
     });
     return user;
}
  
  
function getGroups(user)
{
var groups;
     AJS.$.ajax({
        url: "/rest/api/2/user?username="+user+"&expand=groups",
        type: 'get',
        dataType: 'json',
        async: false,
        success: function(data) {
            groups = data.groups.items;
        }
     });
     return groups;
}
function isUserInGroup(user, group){
    var groups = getGroups(user);
    for (i = 0; i < groups.length; i++){
         if (groups[i].name == group){
              return true;
         }
    }
    return false;
}
    
 });

</script>

Liwei E October 29, 2013

oh, really? we can directly use the jQuery libray? is this default supportive by JIRA?

RambanamP
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.
October 29, 2013

yes, jquery plugin will be included in jira, you can use AJS(Atlassian JavaScript) frame work also

check this

https://developer.atlassian.com/display/AUI/Getting+Started+with+AUI

Sam Huawey September 4, 2015

Funny. Where are you going to put this script? At least you need to have access to Jira working directory (to modify vm templates). And merge your changes each time Jira upgrades. Not really a good way to my opinion.

Tushar Kamble December 6, 2016

Hi Rambanam,

 

Can we use the above script for hiding custom field according to user role permission. Actually my requirement is."Label field should be visible only to admin role users" on create screen.

 

Regards,

Tushar

0 votes
Bharadwaj Jannu
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.
October 27, 2013
0 votes
Bhushan Nagaraj
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.
October 27, 2013

Hi Liwei,

You would need to develop your own custom field to achieve this functionality.

Thank you

Bhushan

Liwei E October 29, 2013

Yes, i currently trying to use some scripts to work around make the 'click to edit' link to be hidden

Bhushan Nagaraj
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.
October 29, 2013

Why not write your own custom field that is editable by selected project roles or groups?

Like Flash_Sheridan likes this

Suggest an answer

Log in or Sign up to answer