It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

Restrict access based on status and user Edited

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

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
Community showcase
Published in Jira

Jira Cloud for Google Sheets: Automatically Refresh Your Data!

Remember that time you realized it was possible to refresh your Jira data in Google sheets with just one click? What if we told you that you can now get the latest data with no clicks at all?! Zero! ...

512 views 3 11
Read article

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you