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

Using ScriptRunner to Create Workflow Validator by User

Hello -

New to ScriptRunner, so bare with me!

Problem: I want to implement "advanced" security that will restrict users from creating a ticket under certain factors..

  • Factor 1: the user must be provisioned to create issues in the system.
  • Factor 2: If the user is attempting to enter a value for Priority on creation of issue, then they must be apart of a Power User group.  
  • Factor 3: If the user not attempting to enter a value for Priority on creation of issue, then they will be allowed to create issue as long as they meet the criteria for Factor 1.

Solution: I thought I may be able to use Workflow and ScriptRunner to implement this.

Implementation: In my workflow, I have the following:

  • Added a validator for the Create transition
  • Validator 1: Only users with Create Issues permission can execute this transition.
  • Validator 2: Script Runner Script

Validator 2 is where I am "stuck" at and need some assistance. I've been looking at guides at what logic to write, but am having trouble piecing together Jira Expressions. None of the examples show if/else logic, so not sure if I can do that with these validators?  Can anyone point me in the right direction? 

1 answer

1 accepted

0 votes
Answer accepted

Hi @Darron Brumsey . How do you want to make Priority field optional? Is it your custom field?

But expression for user + group should be

user.groups.includes("Power User")

If you will clarify the priority "issue", we can complete it :) 

Hi @Martin Bayer _MoroSystems_ s_r_o__ 

Priority is the out of the box field available from JIRA Cloud. It is already set up as optional (by default), and from my understanding that cannot be changed.

 

Is it possible to achieve what I am trying to do with the out of the box Priority field? Or do I need to use a custom field instead?

I just tested it. The true is that Priority is not marked as optional but I can not fill in the blank option. Can you share your Create screen?

ahh, I see what you're saying. 

Yes, Priority cannot be blank. On issue create, our Priority value is set to Unprioritized. 

 

JIRA Priority.png

Therefore the factors change a bit...

  • Factor 1: the user must be provisioned to create issues in the system.
  • Factor 2: If the user is attempting to enter a value other than Unprioritized for Priority on creation of issue, then they must be apart of a Power User group.  
  • Factor 3: If the user not attempting to enter a value other than Unprioritized for Priority on creation of issue, then they will be allowed to create issue as long as they meet the criteria for Factor 1.

Hi @Darron Brumsey I think this Jira Expression should work:

(user.groups.includes("Power User") && issue.priority.name != 'Unprioritized') || issue.priority.name == 'Unprioritized'

Thanks @Martin Bayer _MoroSystems_ s_r_o__ . 

I tested this out and worked perfectly. With this as a baseline, I should be able to figure out anything else I need. Really appreciate your help. 

You're welcome :) Happy to help :)

Suggest an answer

Log in or Sign up to answer
TAGS

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