Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
Deleted user
0 / 0 points
Next:
badges earned

Your Points Tracker
Challenges
Leaderboard
  • Global
  • Feed

Badge for your thoughts?

You're enrolled in our new beta rewards program. Join our group to get the inside scoop and share your feedback.

Join group
Recognition
Give the gift of kudos
You have 0 kudos available to give
Who do you want to recognize?
Why do you want to recognize them?
Kudos
Great job appreciating your peers!
Check back soon to give more kudos.

Past Kudos Given
No kudos given
You haven't given any kudos yet. Share the love above and you'll see it here.

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

ScriptRunner workflow function (Set Issue security level depending on provided condition) Edited

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:

  • Set issue security level depending on provided conditionHelp
    Sets issue security if the provided condition evaluates to true

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:

 

Screenshot_3.png

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

Screenshot_2.pngMaybe 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
}

 

0 answers

Suggest an answer

Log in or Sign up to answer
TAGS
Community showcase
Published in Jira Service Management

JSM June Challenge #2: Share how your business teams became ITSM rockstars

For JSM June Challenge #2, share how your non-technical teams like HR, legal, marketing, finance, and beyond started using Jira Service Management! Tell us: Did they ask to start using it or...

195 views 6 7
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