Forums

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

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

Baybars Kumbasar
Contributor
September 29, 2017

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

2 votes
Answer accepted
Nadir MEZIANI
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
September 29, 2017

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

Baybars Kumbasar
Contributor
September 29, 2017

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? 

Baybars Kumbasar
Contributor
September 29, 2017

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;}

Nadir MEZIANI
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
September 29, 2017

 you could do it like this

If (userInGroup(user_group, reporter){

   security = security_level;

}

Baybars Kumbasar
Contributor
September 29, 2017

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;
}

Baybars Kumbasar
Contributor
September 29, 2017
Baybars Kumbasar
Contributor
September 29, 2017

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? 

Nadir MEZIANI
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
September 29, 2017

@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

Baybars Kumbasar
Contributor
October 2, 2017

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".  

Nadir MEZIANI
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
October 13, 2017

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";

}

Baybars Kumbasar
Contributor
October 13, 2017

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. 

Nadir MEZIANI
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
October 13, 2017

Ok , good luck :)

Suggest an answer

Log in or Sign up to answer