How to set issue security field based on the group membership of the reporter

Hi,

I'd like to have a post-function for issue creation that updates the "security level" field if the reporter of the ticket belongs to a certain group. I haven't been able to find a way to do this with default add-ons or Jira Workflow Toolbox or with "update on transition" add-ons. 

How can I accomplish this? 

1 answer

1 accepted

Hi,

You can do it using a scripting paid plugin like :

Power Scripts for Jira Script Automation (i used it )

ScriptRunner for JIRA

Scripting Suite Pro for JIRA,

or develop you own plugin , or using JavaScript which is not recommended

Okay, I tried PowerScripts for JSA. But I can't find hpw to specify if a user belongs to a group with a statement. Any ideas? 

Basically, I wan to do something along the lines of :

string security_level = "XYZ";
string user_group = "ABC";

if(isUserInGroup(reporter, groups, user_group)) {
security = security_level;}

 you could do it like this

If (userInGroup(user_group, reporter){

   security = security_level;

}

Thanks a lot. I think you missed a closing brackets, but I still get an error saying ">>if<<" is not defined. I really appreciate the help, but I'd not bother you if you could point me to a reference for the syntax. 


If (userInGroup(user_group, reporter))
{
security = security_level;
}

One last question, how do you refer to the "reporter" of an issue? I know currentuser() routine works -> https://confluence.cprime.io/display/SIL/currentUser

but how do I do the same for reporter? 

@Baybars Kumbasar

yes , you found a response :)

https://confluence.kepler-rominfo.com/display/SIL/userInGroup 

the reporter is a standar variable you can look at this link it could help you a know all standard variables

https://confluence.kepler-rominfo.com/display/SIL/Variable+Resolution

Just if the answer is good , pleas could you accept it to help other

thanks in advance

Hi again,

the script looks good to me, it's the most simple script now:

if (userInGroup("XYZ", reporter));
{
security = "Level1";
}

But this doesn't work as expected: Even if the reporter is not a part of "XYZ" group, the issues are created wit "Level1" security level. The default is "Level0".  

Hi @Baybars Kumbasar

Maybe you should see the if the current user is the default level security Level0 else you should add else like this

if (userInGroup("XYZ", reporter));
{
security = "Level1";
}

else{

security = "Level0";

}

Thanks for the response but the error was the semicolon at the end of the "if" statement. I don't feel particularly smart now. All works well now. 

Suggest an answer

Log in or Join to answer
Community showcase
Sarah Schuster
Posted Jan 29, 2018 in Jira

What are common themes you've seen across successful & failed Jira Software implementations?

Hey everyone! My name is Sarah Schuster, and I'm a Customer Success Manager in Atlassian specializing in Jira Software Cloud. Over the next few weeks I will be posting discussion topics (8 total) to ...

2,831 views 12 18
Join discussion

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you
Atlassian Team Tour

Join us on the Team Tour

We're bringing product updates and pro tips on teamwork to ten cities around the world.

Save your spot