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

Next challenges

Recent achievements

  • Global
  • Personal

Recognition

  • Give kudos
  • Received
  • Given

Leaderboard

  • Global

Trophy case

Kudos (beta program)

Kudos logo

You've been invited into the Kudos (beta program) private group. Chat with others in the program, or give feedback to Atlassian.

View group

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

Read only field- only in view screen

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

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)

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).

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

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)

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

def descField = getFieldById("description")
descField.setAllowInlineEdit(false)

Thanks! Works like a charm :) 

@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

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.

@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. :/ 

@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?

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.

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
Joe Pitt Community Leader Jan 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. 

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 ?

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.

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
TAGS

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