Hi,
I have the next behaviour to define the security level and it works correctly but I need that if it doesn´t meet the conditions select the default security level defined in the scheme.
The code:
import com.atlassian.jira.component.ComponentAccessor
if (getActionName () == "Create") {
finalSecurity level = "Deployment"
final secLevel = ComponentAccessor.getIssueSecurityLevelManager (). getUsersSecurityLevels (getIssueContext (). projectObject, ComponentAccessor.getJiraAuthenticationContext (). getLoggedInUser ()). findAll {
it.name.contains (securityLevel)
}
if (! secLevel.id.empty) {
getFieldById ("security"). setFormValue (secLevel.id)
getFieldById ("security"). setReadOnly (true)
}
}
The function that I think I need is "getDefaultSecurityLevel":
https://docs.atlassian.com/software/jira/docs/api/7.1.6/com/atlassian/jira/issue/security/IssueSecurityLevelManager.html#getDefaultSecurityLevel-com.atlassian.jira.project.Project-
but I dont know how to apply it.
Could you help me?
The version of Jira that I use is 7.6.4 and the scriptrunner version is 5.3.16.
Thank you very much.
Greetings,
Alex
Hi,
Finally works with this code:
import com.atlassian.jira.component.ComponentAccessor
if (getActionName() == "Create") {
if (issueContext.issueType.name == "Deployment"){
final level= "Deployment"
final secLevel = ComponentAccessor.getIssueSecurityLevelManager().getUsersSecurityLevels(getIssueContext().projectObject,ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser()).findAll {
it.name.contains(level)
}
if (!secLevel.id.empty){
getFieldById("security").setFormValue(secLevel.id)
getFieldById("security").setReadOnly(true)
}
}
else {
final project= getIssueContext().getProjectObject()
final defaultSecurityLevel = ComponentAccessor.getIssueSecurityLevelManager().getDefaultSecurityLevel(project)
getFieldById("security").setFormValue(defaultSecurityLevel)
getFieldById("security").setReadOnly(false)
}
}
Thanks,
Alex
Any idea?
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.