Just a heads up: On March 24, 2025, starting at 4:30pm CDT / 19:30 UTC, the site will be undergoing scheduled maintenance for a few hours. During this time, the site might be unavailable for a short while. Thanks for your patience.

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

Lock editing of all the fields if checkbox is checked in jira

Krithica Gowri Shankar
Contributor
October 11, 2018

Hi,

If we want to add a checkbox that says “Approved”, once the box is checked, can we lock down all of the fields in the form so that they can no longer be edited?

How to achieve this? Please help.

Thanks,

Krithica

2 answers

0 votes
Prakhar Srivastav {Appfire}
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 12, 2018

@Krithica Gowri Shankar

Scriptrunner Behaviour Plugin can help you in this case.

https://scriptrunner.adaptavist.com/4.3.1/jira/behaviours-overview.html

There are examples of making a field manadatory and hidden based on data entered on other field. You might need to tweak them to suit your case.

Writing javascript yourself is another way without using plugin.

Regards

Prakhar

Krithica Gowri Shankar
Contributor
October 12, 2018

I tried using behavior scripts. once the field is set read only again it is not editable even if all options are unchecked in checkbox.

I am using below script.

def checkboxesfield = getFieldByName("checkboxes");
def reqtypefield  = getFieldByName("Request Type");
def team = getFieldByName("Team");

def selectedOption = checkboxesfield .getValue() as String
log.debug("checkboxesfield " + checkboxesfield .getValue())

if(selectedOption != "")
{
reqtypefield .setReadOnly(true);
team.setReadOnly(true);

}
else if(selectedOption == "")

{
reqtypefield .setReadOnly(false);
team.setReadOnly(false);

}

Prakhar Srivastav {Appfire}
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 12, 2018

@Krithica Gowri Shankar

 

The catch here is with comparing the checkbox field values. It is not same as text field values. You can find some documentation here :

https://scriptrunner.adaptavist.com/latest/jira/recipes/behaviours/setting-default-fields.html#_setting_defaults_for_selects_etc

 

Regards

Prakhar

0 votes
Matthias Gaiser _K15t_
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 11, 2018

Hi @Krithica Gowri Shankar,

I don't know of a way to exactly do what you describe, but I'd propose an alternative:

You could add to your workflow an extra "Approved" status and create a transition from the desired status fields and name it, e.g. "Approve". Furthermore, on the "Approved" status you would have to set the jira.issue.editable property to false, see the Atlassian docs for more details.

With this solution you would simply have an "Approve" button on each issue to achieve what you need.

Cheers,
Matthias.

Krithica Gowri Shankar
Contributor
October 12, 2018

With workflow status property issue itself will become non editable. Based on the values in the field need to set other fields read only.

Checkbox= Checked for Yes--> then i want the fields to be read only. But i should be able to transition issues to next stages.

Checkbox = Checked for No -- All fields editable and should be able to perform workflow transition

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events