You're on your way to the next level! Join the Kudos program to earn points and save your progress.
Level 1: Seed
25 / 150 points
Next: Root
1 badge earned
Challenges come and go, but your rewards stay with you. Do more to earn more!
What goes around comes around! Share the love by gifting kudos to your peers.
Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!
Join now to unlock these features and more
The Atlassian Community can help you and your team get more value out of Atlassian products and practices.
Hi Atlassian Community, im looking for solution to set Issue security Level based on custom field value.
I find the best way to do this by using ScriptRunner workflow function:
Description:
We have custom filed "Teams".
We have values "Team first"; "Team Second"
We have issue security level, and one of this level which called "Administration Task SL"
Also i find id of this custom field value id of one of parameter "Team first = 11700"
But im new in this scripts and always get an error:
All screen how i try to do this
1) use transition on which i need to change issue security level
2) try to add postfunction from ScriptRunner workflow function (Set Issue security level depending on provided condition)
3) SetName of security level
4) Got issue's in code
Maybe im doing something wrong or not define some values.
Here are my code:
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.security.IssueSecurityLevelManager
import com.atlassian.jira.issue.security.IssueSecuritySchemeManager
def project = issue.getProjectObject()
def projectComponentManager = ComponentAccessor.getProjectComponentManager()
def issueSecuritySchemeManager = ComponentAccessor.getComponent(IssueSecuritySchemeManager)
def issueSecurityLevelManager = ComponentAccessor.getComponent(IssueSecurityLevelManager)
def customFieldManager = ComponentAccessor.getCustomFieldManager()
def issueManager = ComponentAccessor.issueManager
def cfValue =customFieldManager.getCustomFieldObjectByName("Teams")
if (cfValue == 'Team first') {
issue.setSecurityLevelId(11700)
}
Maybe somebody meet this before? or can help me how to correct define condition?
Or somebody know how to make, becose we need to use one of two issue security level based on custom field. Maybe i need something different?
if (cfValue == 'Team one') {
issue.setSecurityLevelId(null)
} else if (cfValue == 'Team second') {
issue.setSecurityLevelId(secLevel.id)
} else {
//something else
}