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:
Any ideas how to go about this?
Thanks.
In your behavior configuration, add (using the drop-down at the bottom) each of the fields you want your script to impact. You don't need to configure anything on each of those fields.
When a field is listed like that, then the "inline edits" are disabled. If you click on the edit button for the field, the full edit screen is displayed and your script will take effect.
Behavior is not able to hide or set as read-only on the view screen, all it can do is force the full edit screen.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.