Forums

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

Transition workflow: stop assignee user - Jira 6.4

Marco Campeotto August 1, 2018

Hi all,

before to write this question I searched a lot in community and Jira confluence documentation... I will try to explain the situation.

I think the "obstacle" of my project it is the version of jira server available... I have only possibility to use Jira server 6.4.14.

I have this setup for my project:

Add-ons available
Adaptavist ScriptRunner for JIRA Standard Edition - Installed version: 3.1.4
JIRA Misc Custom Fields - Installed version: 1.6.4
JIRA Automation - Installed version: 1.5.10

Roles:
- Users: all users - only permission to see issues in project
- Operators: users with right to modify issues, no permission to transition issues
- Reviewers: (small group of Operators) user with permission to modify and to transition the issues
- Admin: all permission - 1 user (it is not possible to assign issue to Admin)

For each Status of my workflow (17) there are two options of transition: PASS or FAIL

when Reviewer check the edits/actions of Assignee (Operators or Reviewers user as well) of issue, he decide if it is PASS or FAIL.

The problem is this, if user A is a Reviewers and A is the Assignee of issue, he have the permission to modify and to transition the issue in the workflow without control.

So I want to remove the permission to transition of the Assignee user.

I tried to use validators or conditions in workflow but I don't find a solution. (I attach the possibility of condition and transition)

Condition_transition.PNGValidator_transition.PNG.


I tried to add a Group Custom Field (but it is possible to select: checkbox, select list or epic status)Group-custom-fields.PNG or a User picker (multiple users but I need each time to select the users and I don't know how to integrate this in the permission of transition) but I don't know how to use this...


Last option it is to write a ScriptRunner code but I didn't find a guide to write and what to import in the method and which is the function to call to extract the list of users of group.


I know I have little possibility with this settings but this is my situation... :(


Thank you for your time, Regards
Marco

2 answers

1 vote
Thomas Schlegel
Community Champion
August 1, 2018

Hi @Marco Campeotto,

you can use Scriptrunner Script Condition like this: 

First: choose "Simple scripted condition"

 

image.png

Then add the following condition:

currentUser != issue.assignee

 

That should do what you want.

Marco Campeotto August 2, 2018

Hi @Thomas Schlegel thank you for the answer but it doesn't work.


I tried simple scripted condition only for PASS button and I understand this, if condition is:

- FALSE the button is not visible
- TRUE the button is visible

I tried other simple scripted and they work!

- Current user is in Administrators role (or other role) :
isUserMemberOfRole('Administrators')

- Reporter is in a particolar group (E.g. if Andrea is not in Reviewers, the button is not visible for everybody)

import com.atlassian.jira.component.ComponentAccessor

def groupManager = ComponentAccessor.getGroupManager()

groupManager.isUserInGroup(issue.reporter?.name, 'Reviewers')



I tried this simple scripted

- Reporter is current user
currentUser == issue.reporter

condition_assignee-reporter.PNG


but it doesn't work! I don't understand why but it doesn't work...

the result is this if I am login with Marco and Andrea user

andrea_situation.PNGmarco_situation.PNG


It is visible only the FAIL button even if Andrea is the Reporter of issue and I am login with his profile...

Marco Campeotto August 2, 2018

I think there is a "problem" with the "currentUser" instruction...


I tried your condition in "positive" and "negative"

currentUser == issue.assignee : nobody see the button

currentUser != issue.assignee : all users with transition issues permission see the button

Transition Issues Ability to transition issues.
  • Project Role (Reviewers) 
 
Thomas Schlegel
Community Champion
August 2, 2018

Hi @Marco Campeotto,

I tried the same, and it is working perfectly for me with the script "currentUser == issue.reporter".

Did you publish your workflow after changing it?

Marco Campeotto August 2, 2018

Hi @Thomas Schlegel,yes of course, in fact if I use the simple scripted "Reporter in group" or "current user in specific role" they work....

I don't know why... uff...

Thomas Schlegel
Community Champion
August 2, 2018

Just for clarification: 

- you have tow workflow transitions: fail and pass

- you set conditions only to the pass-button

- The pass button is not active, no matter which script you add

right?

Marco Campeotto August 2, 2018

- Yes
- Yes
- depend on the script...


if I use for example the script:

isUserMemberOfRole('Reviewers')


all users in this role have the possibility to click on PASS button -> so this script works

If I use the script:

issue.priority?.name == 'High'

the PASS button is not visible as long as the priority is not equal to "High" -> works


if I use the script:

currentUser == issue.assignee : nobody see the button

currentUser != issue.assignee : all users with transition issues permission see the button

-> doesn't work (all users see and press the button, not only Marco)

If I use the script:

currentUser == issue.reporter

there is the screenshot above with Reporter = Andrea (black hair avatar) and login with Marco (brown hair avatar) and Andrea.... Andrea doesn't see the PASS button

-> doesn't work


@Thomas SchlegelI know... it is so wired... and I don't understand why...


Marco Campeotto August 2, 2018

@Thomas Schlegelwhich is the version of your Jira?

is it possible I forgot to tip/check some settings/setup to ability all function?

Marco Campeotto August 2, 2018

@Thomas SchlegelI have "news"... 

I tried to use the Preview using an Issue key and the result is this

Preview_cp14_button_assignee.PNGit

It is really wired!

when I tried this I am login with Marco account and the Issue CP-14 is the same of screenshot above (Assignee Marco - Reporter Andrea)

the condition if I press Preview is correct! (I am login with Marco, so the currentUser is not different of issue.assignee -> false, so the button should not visible) but when with user Marco I show the CP-14 I have the possibility the PASS button and the Issue goes to the next status....

Thomas Schlegel
Community Champion
August 2, 2018

could you please check this JQL: 

key = CP-14 and assignee = marco

Marco Campeotto August 3, 2018

i used the JQL:

key = CP-14 and assignee = macampe


because the username is macampe, not marco and the result is one issue (CP-14)... the JQL is correct

I tried only the JQL: assignee = macampe

and the result is only the 3 issues in all my 2 project, the result is correct


so I don't know why the simple scripted condition

currentUser != issue.assignee

in preview mode (using key CP-14 or the issues in the second JQL) works (the result is False because currentUser is macampe and the issue.assignee is macampe)

but if I view the issue with macampe user the button is visible and clickable...

Thomas Schlegel
Community Champion
August 3, 2018

@Marco Campeotto - to be honest, I'm running out of ideas - I will ask for assistance in our internal chat and hopefully, one of the other champions has another idea.

miikhy
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.
August 3, 2018

Hey there,

Coming after @Thomas Schlegel's message in Stride :)

Have you tried getting the user with:

JiraAuthenticationContext jac = ComponentAccessor.getJiraAuthenticationContext();
ApplicationUser user = jac.getLoggedInUser();

The common error I have with users is when they have a different user_name and user_key! You can check if Marco is affected with a simple SQL query (if you can run it in your db):

SELECT * FROM app_user WHEN lower_user_name <> user_key;

It's frequent, especially when renaming a user!

Hope this helps!

0 votes
Marco Campeotto August 7, 2018

Hi @Thomas Schlegel and @miikhy, htank you for your time.

I am a new member and I tried in the simple scripted condition only to copy and paste:

from
currentUser != issue.assignee

to

no_import.PNG

probably it is necessary to import some classes, but I don't know which classes

So I tried with these import (I searched on Altassian JIRA 6.4.14 API and I found these)

https://docs.atlassian.com/software/jira/docs/api/6.4.14/com/atlassian/jira/component/ComponentAccessor.html

https://docs.atlassian.com/software/jira/docs/api/6.4.14/com/atlassian/jira/user/ApplicationUsers.html

(If I used component.ComponentAccessor and user.ApplicationUsers the error were the same of without import)

import.PNG

 I tried to extend the import to com.atlassian.jira.*; but the result was the same.

could you help me please?

miikhy
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.
August 7, 2018

Hey,

You're missing the com.atlassian.jira.security.JiraAuthenticationContext import here, whenever grrovy suggest a class cannot be resolved, you should go in the javadoc and look for its name ;-)

Hope this helps!

Cheers

Marco Campeotto August 8, 2018

Hi @miikhy, right... sorry I didn't read with attention the error message.

but I have an other error message, now the script is this

import com.atlassian.jira.*;
import com.atlassian.jira.user.*;
import com.atlassian.jira.security.JiraAuthenticationContext;
JiraAuthenticationContext jac = ComponentAccessor.getJiraAuthenticationContext();
ApplicationUser user = jac.getLoggedInUser();
user.getUsername() != issue.assignee

the message is below and I don't know what to do.
no_property.PNG

miikhy
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.
August 8, 2018

Hi Marco,

If you're not familiar with Java you should definitely get help from a developper as we can't write and maintain scripts with/for you on Community.

That being said, I'm always willing to help and it seems like

import com.atlassian.jira.component.ComponentAccessor;

would help!

Cheers, good luck!

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events