Behaviours allow you to change how fields behave on issue Create or Update screens. Using this script, you can set a field as read-only on these screens, so the user cannot edit it.
As an admin, I want to disable a field temporarily so users can't update it for a specified time. I use this script to make the field read-only for a set time, after which it is editable again.
1
2
3
4
5
6
7
8
9
10
11
12
13
import com.atlassian.jira.issue.IssueFieldConstants
import com.onresolve.jira.groovy.user.FieldBehaviours
import groovy.transform.BaseScript
@BaseScript FieldBehaviours fieldBehaviours
final String fieldName = "TextField"
// get field by name and make it read only
getFieldByName(fieldName).setReadOnly(true)
// get field by id and make it read only
getFieldById(IssueFieldConstants.DUE_DATE).setReadOnly(true)