Read only field- only in view screen

Dan27 January 16, 2019

Hi,

 

I need to made a text field 'read only' only in edit screen (The user can change this field in the edit and create screen).

 

BR,

Daniel

3 answers

1 accepted

1 vote
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.
January 16, 2019

Um, your question says "make text field read-only in edit screen" then "the user can change this field in edit screen" - which one is it? 

Or do you mean you just want to be able to stop all edits of the field after creation?  (To do that, remove it from the edit screen)

Dan27 January 16, 2019

Hii @Nic Brough -Adaptavist-

I mean this:

In the create screen user can put value in this field.

In edit screen- user can change the value and update this field.

In view screen- the field will be read only (If the user wants to change, he will need to press the 'Edit' bottom).

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.
January 16, 2019

Ah, ok.  You have a problem then - the standard way to tell Jira a field cannot be edited in "view" is to remove it from the edit screen.  The "inline edit" is a friendly way of making Jira quicker and easier for your users - changing a field becomes three clicks instead of 6.

If you want to disable inline edit while keeping the ability to change a field then consider these:

  • Don't - inline edit is useful, and most people use it well.  New users who have used Jira before will find this restrictive, intrusive and annoying.
  • Move the edit of the field into the workflow - remove it from the edit screen, but put it on transition screens that prompt users as they move through the flow.  This also has the advantage that you can limit who can edit the field.
  • Use Behaviours in the ScriptRunner app to block inline edit for the field
Like Dave Liao likes this
Dan27 January 17, 2019

Thank you @Nic Brough -Adaptavist- ,

How can I do the third bullet? I can make a field 'read only' , but at all of the screens (view + edit).

I would like to 'read only' only in inline edit (view screen)

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.
January 17, 2019

Ok, use a Behaviour that is an "initialiser" and says

def descField = getFieldById("description")
descField.setAllowInlineEdit(false)
Dan27 January 19, 2019

Thanks! Works like a charm :) 

Eduard Diez
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.
February 11, 2019

@Nic Brough -Adaptavist-

is possible to put a customfield in the transition but in only read, only in the transitions that I need, but in JIRA CLOUD, not in Server.

Thank's

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.
February 11, 2019

No.  If you put a custom field on a transition screen, it is there to be edited by the user, not read-only.  Behaviours can change that, but Cloud does not support the type of code Behaviours needs to inject to do this (yet), so there are no behaviours for Cloud.

Azfar Masut
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.
August 13, 2019

@Nic Brough -Adaptavist- behaviour seems to have an issue where the scripts kicks in rather slow. If you are fast enough to click the field <3 sec, the inline edit would still be available. :/ 

Darin Hafer January 7, 2020

@Nic Brough - thank you for your involvement in the Community. With Jira 7.9.2 and Scriptrunner 5.6.9, I can't seem to disable inline editing on view screen, for a custom date picker field, using the simple 2 lines above with an initializer. It remains editable on view screen in the Dates section. Would you expect this to work for a date picker?

Taylor Huston January 14, 2020

I am also unable to get this to work on a simple text field.

def logField = getFieldById("customfield_10235")
logField.setAllowInlineEdit(false)

I am sure I am grabbing the right field as I have been able to get the setHidden() and setReadOnly() functions to work on it.

Hemant August 4, 2020

I am unable to get this to work as well. I have around 50 fields some of which are being made read only depending on the group a user belongs to. If he belongs to x group, he can edit otherwise he cannot. This functionality works perfectly fine in the edit screen but users are able to edit fields in view screen using inline edit. 

This is a functionality we really need to get to work and disabling inline edit for the whole JIRA seems to be the only option we are left with (which is horrible) . Are there any other ways i can disable inline edit just for a single issuetype/ workflow. @Nic Brough -Adaptavist- @Joe Pitt 

I tried using the setAllowInlineEdit(false) in the behaviour initializer. Does not work

0 votes
Sema YILDIRIM August 13, 2020

Can you help me? Sorry, I couldn't run it. I made it readonly in Select List custom field custom options. But I don't want it to be read only when changing options on the edit screen.

 

if (getAction()?.id == 1)
{
return
}

def CustomField = getFieldByName("Request Type")


def selectedOption = CustomField.getValue() as String

def isOtherSelected = (selectedOption == "Defect" || selectedOption == "New Feature")

CustomField.setReadOnly(isOtherSelected);

 

If "Request Type" Defect or New Feature is selected, get readonly. Example "Request Type" Test selected. Later, when it is called edit, I do not want read only when Defect is selected.

0 votes
Joe Pitt
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
January 16, 2019

If they can edit the field then it isn't defined as read only. If you are setting it in the background remove it from the edit and view screens. If you don't have separate create, edit, and view screens you need to create them instead of just using the default screen for all functions. 

Dan27 January 16, 2019

Hi @Joe Pitt ,

In view screen- the field will be read only (If the user wants to change, he will need to press the 'Edit' bottom)...

Is it possible ?

Sema YILDIRIM August 13, 2020

Can you help me? Sorry, I couldn't run it. I made it readonly in Select List custom field custom options. But I don't want it to be read only when changing options on the edit screen.

 

if (getAction()?.id == 1)
{
return
}

def CustomField = getFieldByName("Request Type")


def selectedOption = CustomField.getValue() as String

def isOtherSelected = (selectedOption == "Defect" || selectedOption == "New Feature")

CustomField.setReadOnly(isOtherSelected);

 

If "Request Type" Defect or New Feature is selected, get readonly. Example "Request Type" Test selected. Later, when it is called edit, I do not want read only when Defect is selected.

Suggest an answer

Log in or Sign up to answer