Hi,
The below behaviour script is not working for multi cascade select field.
It is hiding the multi select custom field on the edit screen for a project role member for a specific issue type but not working for multi cascade select custom field.
The multi cascade select custom field is coming from a plugin.
Can anyone please help with the correction?
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.security.roles.ProjectRoleManager
import com.onresolve.jira.groovy.user.FieldBehaviours
import groovy.transform.BaseScript
import static com.atlassian.jira.issue.IssueFieldConstants.ISSUE_TYPE
@BaseScript FieldBehaviours fieldBehaviours
// Get the custom field manager def customFieldManager = ComponentAccessor.getCustomFieldManager()
def projectRoleManager = ComponentAccessor.getComponent(ProjectRoleManager)
def user = ComponentAccessor.jiraAuthenticationContext.loggedInUser
def issue = underlyingIssue
// Define the issue type, restricted roles, screen, and restricted statuses
def restrictedIssueType = "Project"
def restrictedRoles = ["Product Owner"]
def restrictedStatuses = ["Initial Review", "Demand Committee Review", "In BA Queue", "BRD Review", "BRD Preparation", "User Story Preparation", "In UI/UX Queue", "UI Design", "UI Review", "In Delivery Queue", "In Design Queue", "SBP Preparation", "LLD Preparation", "SOW Review", "SOW Preparation", "Planning", "Development", "Ready For SIT Deployment", "SIT Release Deployment", "Ready For Testing", "QA Execution", "QA Blocked", "UAT", "Ready For UAT", "UAT Verification", "UAT Blocked", "Go-Live Preparation", "TAB Review", "CAB approval", "PIV", "Production Deployment", "Market Live", "Business Inputs", "Pending-Control Function Approval", "On-Hold", "Cancelled"]
def screen = 'TEST: ARC Edit screen.TEST'
// Check if the issue type matches the restricted issue type
def isIssueTypeRestricted = (issue.issueType.name == restrictedIssueType) log.warn""+isIssueTypeRestricted
// Get user roles in the project
def userRoles = projectRoleManager.getProjectRoles(user, issue.projectObject)*.name log.warn""+userRoles
// Check if issue status is in the restricted statuses
def isStatusRestricted = restrictedStatuses.contains(issue.status.name) log.warn""+isStatusRestricted
// Check if user is in any restricted roles
def isUserRestricted = userRoles.any { it in restrictedRoles }
log.warn""+isUserRestricted
def isScreenName = (fieldScreen.name == screen)
log.warn""+isScreenName
// Target specfic fields
def multiSelectField = getFieldById("customfield_12804")
def multiCascadeField = getFieldById("customfield_16503")
if (isIssueTypeRestricted && isStatusRestricted && isUserRestricted && isScreenName) { log.warn"yes"
//getFieldIds().each { fieldId ->
//getFieldById(fieldId).setReadOnly(true)
multiSelectField?.setHidden(true)
multiCascadeField?.setHidden(true)
}
else { //getFieldIds().each { fieldId ->
// getFieldById(fieldId).setReadOnly(false)
multiSelectField?.setHidden(false)
multiCascadeField?.setHidden(false)
}
Regards,