Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Script Runner - Script transition validator

wajih zouaoui
Contributor
November 20, 2018

Hi,

 

i'm trying to put a script with script-runner to make a validator in a transition and it's look like:

 

import com.atlassian.jira.component.ComponentAccessor

def groupManager = ComponentAccessor.getGroupManager()
(
groupManager.isUserInGroup(issue.reporter?.name, 'group1') ||
groupManager.isUserInGroup(issue.reporter?.name, 'group2') ||
groupManager.isUserInGroup(issue.reporter?.name, 'group3')
)

 

I want to all the users in those groups to be able to create an issue using a specific issue type and if it's not true an error message must be shown.

 

Thanks in adavance.

1 answer

0 votes
Tom Lister
Community Champion
November 20, 2018

Hi

when you set up a validator with scriptrunner you have a form field to enter an error message.

this is shown against a selected field of your condition is false

wajih zouaoui
Contributor
November 20, 2018

Hi,

 

thanks for your answer.

Yep i have already entered the error message and it works but the issue that i have is the error message is shown for the users contained in the 'group3' and it's aginst the condition in this script.

I don't  know the reason why and i think maybe i have an error or something wrong .

Tom Lister
Community Champion
November 20, 2018

I guess those aren't the real group names - typo? I get blind to looking at my own code for too long and often miss the obvious.

is that your complete code block?

wajih zouaoui
Contributor
November 20, 2018

those aren't the real group names for surebut i have putted 3 different groups.

yeah ths is the complete code block.

Tom Lister
Community Champion
November 20, 2018

Hi

There is nothing wrong with the syntax of the checking as you can see for yourself.

option is to get group objects to check if there's an issue with that.

groupManager.getGroup('group3')

this will return null is there's an issue accessing that group

try logging it


log.debug "group3" + groupManager.getGroup('group3')


All I can suggest

wajih zouaoui
Contributor
November 20, 2018

Hi,

 

that returns a null when logging that line.

I don't know whay to do but i will try to follow everything from the beginning i think that something escapes me.

 

Thanks a lot for the time and the effort.

Suggest an answer

Log in or Sign up to answer