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)
.
I tried to add a Group Custom Field (but it is possible to select: checkbox, select list or epic status) 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
Hi @Marco Campeotto,
you can use Scriptrunner Script Condition like this:
First: choose "Simple scripted condition"
Then add the following condition:
currentUser != issue.assignee
That should do what you want.
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
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
It is visible only the FAIL button even if Andrea is the Reporter of issue and I am login with his profile...
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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. |
|
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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...
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
- 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...
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
@Thomas Schlegelwhich is the version of your Jira?
is it possible I forgot to tip/check some settings/setup to ability all function?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
@Thomas SchlegelI have "news"...
I tried to use the Preview using an Issue key and the result is thisit
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....
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
could you please check this JQL:
key = CP-14 and assignee = marco
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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...
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
@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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
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)
(If I used component.ComponentAccessor and user.ApplicationUsers the error were the same of without import)
I tried to extend the import to com.atlassian.jira.*; but the result was the same.
could you help me please?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.