Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

How to make a field read only based on status

Jamis A. Mack January 10, 2023

As an admin, I'd like to make all but three fields read only after a certain transition.

Further, I'd like to make all fields read only once the ticket is closed.

 

2 answers

2 accepted

1 vote
Answer accepted
Vamsi Kandala
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.
January 10, 2023

Hi,

To make all fields read-only once the ticket is closed, you will have to set the property that status:

Property Key = jira.issue.editable

Property Value = false

For making some of the fields read only after a certain transition, you can try using the workflow post functions for this transition.

Hope this helps.

Thanks,
Vamsi

Raimon Colmenares
Contributor
January 10, 2023

Hey Vamsi, thanks for this! 

Jamis A. Mack January 11, 2023

Thank you for your response.

The solution for making all of the fields read-only works. However, I have not found any post function that can set a field at this level.

Vamsi Kandala
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.
January 11, 2023

Hi @Jamis A. Mack

If you have ScriptRunner installed, you can use Behaviors to implement this.

def custom_field_1 = getFieldById("customfield_12345")
def custom_field_2 = getFieldById("customfield_67890")


if (underlyingIssue.getStatus().name == "Status Name") {
    custom_field_1.setReadOnly(true);
    custom_field_2.setReadOnly(true);
}
else {
    custom_field_1.setReadOnly(false);
    custom_field_2.setReadOnly(false);

}

Hope this helps.

Thanks,
Vamsi

Like Jamis A. Mack likes this
Mohammed Monir
Contributor
May 12, 2023

Will this work in Behaviors Cloud? How can we restrict the field for group or role?

Like Boris Alyurov likes this
Boris Alyurov January 12, 2024

Is this something that Jira cloud supports?

Mohammed Monir
Contributor
April 22, 2024

try something like this

 

const triggerField = getFieldById('customfield_11609');

const showField0 = getFieldById('customfield_11610');

const showField1 = getFieldById('customfield_11611');

 

const triggerFieldValue = triggerField.getValue().value

 

    switch (triggerFieldValue) {

      case 'Yes':

        showField0.setVisible(true);

        showField0.setRequired(true);

        showField1.setVisible(true);

        showField1.setRequired(true);

        break;

      case 'No':

        showField0.setVisible(false);

        showField0.setRequired(true);

        showField1.setVisible(false);

        break;

}

 

OR

 

const triggerField = getFieldById('customfield_11609');
const showField0 = getFieldById('customfield_11610');
const showField1 = getFieldById('customfield_11611');

const triggerFieldValue = triggerField.getValue().value

if (triggerFieldValue == 'No') {
showField0.setVisible(false);
showField0.setRequired(false);
showField1.setVisible(false);
showField1.setRequired(false);
}
else {
showField0.setVisible(true);
showField1.setVisible(true);
}
0 votes
Answer accepted
Nic Brough -Adaptavist-
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.
January 10, 2023

Jira doesn't have a function for this.

There is an ugly "fix" for it, which involves moving all of your "edit" functionality into the workflow, but I doubt you really want to do it.

Jamis A. Mack January 11, 2023

Just for giggles, how would that work?

Nic Brough -Adaptavist-
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.
January 11, 2023

You remove the fields you don't want people to edit from the "edit" screen for the issue type, then edit the workflow, adding looped transitions that use a screen that does have the fields.  You add them to any status that you want to allow fields to be edited. Looped transitions go back to where they started, they don't appear to change the status, but they can take you through a different "edit" screen.

It's ugly, but it does the job.

Like # people like this

Suggest an answer

Log in or Sign up to answer