Restrict access based on status and user

Marco Kuper September 9, 2019

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.

1 answer

0 votes
Peter-Dave Sheehan
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
September 20, 2019

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.

Suggest an answer

Log in or Sign up to answer