Just a heads up: On March 24, 2025, starting at 4:30pm CDT / 19:30 UTC, the site will be undergoing scheduled maintenance for a few hours. During this time, the site might be unavailable for a short while. Thanks for your patience.
×Hello all,
I am currently trying to find out how to use Scriptrunner's Behaviors functionality to hide a custom field (multi user select field) based on the Issue Security Level of the issue. In an ideal world, I would like to have the field "Watchers" be hidden (creating/editing/viewing) when the Security Level name contains/starts with "Confidential".
Is there an easy way to do this in behaviors? I have tried many attempts with different answers from the past questions on this forum, but none seem to work. I think the main issue is that the Security Level field acts differently from standard custom fields (or at least I think it does). I am also open to hard coding the level IDs as the condition, but preferably if the string match method could work that would be ideal.
Any help would be greatly appreciated! Thank you!
You can't hide a custom field in view screen with Behaviour: limitations (screen), community answer.
Also, you "Watchers" field is not available in create and edit screen. It is not exactly a field.
Having said that, you can hide the other field in create and edit screen with:
import com.atlassian.jira.component.ComponentAccessor
def issueSecurityLevelManager = ComponentAccessor.getIssueSecurityLevelManager()
def securityLevelName = issueSecurityLevelManager.getIssueSecurityName(getFieldById(getFieldChanged()).getValue() as Long)
if (securityLevelName?.contains("Confidential")) {
getFieldByName("Your Field").setHidden(true)
} else {
getFieldByName("Your Field").setHidden(false)
}
Should I be putting this code in the Initialiser or on the field? For some reason either method doesn't work. The Watchers field is a custom multi user select field, not the standard Watchers field from Jira. I have renamed it to Procurement Watchers to avoid confusion. I would only need to hide it in create or edit anyways, if the field was empty it would not show in the View screen.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You need to attach it to the issue "Security Level" field. I have tested it in my local machine, it works fine.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Okay my issue was that I was attaching it to the Procurement Watchers field, your method is exactly what I was looking for. Thank you very much!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
No problem! Glad to help!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.