I am trying to restrict access to certain fields (i.e. make them read-only) for a certain user and only if the issue is has a certain status.
The closest I have come to achieving this so far has been using a behaviour script in scriptrunner. My attempt basically looks like this:
import com.atlassian.jira.issue.status.category.StatusCategory
// Safe guard if the issue does not exist
if (!underlyingIssue) {
return
}
def fieldsToBlock = ["priority", "summary", "description", "issuetype"]
def restrictedStatus = ["In Progress", "Complete"]
def statusCategory = underlyingIssue.getStatus().getStatusCategory().getName()
if (statusCategory in restrictedStatus) {
for (fieldId in fieldsToBlock) {
getFieldById(fieldId).setHidden(true)
}
}
I have tried two ways to restrict the access: hiding the fields (as in the example above) or setting it to read-only via the appropriate field API.
Both cases work except for the following:
- The fields are only restricted/hidden in the "Edit"-form. I can still edit the fields in place.
- The description field has no restriction in either method I've tried.
Any ideas how to go about this?
Thanks.