Hi Team,
Below requirement in JIRA SERVER.
I have a multi user picker custom field like "Viewers".
When I add the users in the "Viewers" field in the create and edit issue, people in this field are automatically added to the "Developers" project role.
Viewers(custom multi user picker field) --> Developers (role)
--> I have Script Runner and JMWE add-ons.
Thanks
Hi @cloud jira ,
first of all, you specified "Cloud" as your deployment type when posting this question, but you mentioned you want the answer for Jira Server. That's confusing.
Anyway, on Jira Server, you can create an Event-based Action from JMWE that listens to changes to the Viewers field and add a Scripted (Groovy) post-function to that action with a script like:
import com.atlassian.jira.bc.projectroles.ProjectRoleService
import com.atlassian.jira.util.SimpleErrorCollection
import com.atlassian.jira.security.roles.ProjectRoleActor
ProjectRoleService prs = getComponent(ProjectRoleService)
SimpleErrorCollection errCollection = new SimpleErrorCollection();
def projectRole = prs.getProjectRoleByName("Developers", errCollection)
def userKeys = issue.get("Viewers")*.key
prs.addActorsToProjectRole(userKeys, projectRole, issue.projectObject, ProjectRoleActor.USER_ROLE_ACTOR_TYPE, errCollection)
Hi David,
I am facing a problem.
--> If I remove users from the "Viewers" field they should leave the role automatically. (This function is not happening automatically)
--> If I add multiple users in the "Viewers" field at onetime, all those who have added are being added in the "Developers" role automatically.
--> If I add one user in the "Viewers" field, that user is adding in the "Developers" role automatically.
--> If I added 2nd, 3rd users after adding the first user in the "Viewers" field. 2nd, 3rd users are not adding in the "Developers" role.
Note: After adding 1st user, if I add one or multiple users in the "Viewers" field, all those who have added are not being added in the "Developers" role automatically.
-->For ex: I have added Anitha in the Viewers field, again I want to add one more user Srilakshmi along with Anitha, So I added Srilakshmi with Anitha. But Srilakshmi is not adding in the Developers role.
Please find below image.
Please help me in this.
Thanks.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
@Vinodh ,
can you share the configuration of the event-based action you have configured?
As for removing users who were removed from the Viewers field from the project role, this is more complicated as the user could be in the Viewers field of two issues, and if you remove that user from the Viewers field of only one issue, you shouldn't remove that user from the project role since they are still mentioned in the Viewers field of the other issue. Or did I misunderstand something?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
There is small misunderstanding, let me give you a clear view
For ex: I update viewers multi user picker field with one user and after sometime I may require couple of users additionally to be added. During this case the first user gets updated properly but the users updated aftr sometime is not getting updated in the project roles.
And when we update multiple users at a single go it's working fine,but adding users at multiple intervals are not getting updated
Regards
Vinodh A
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Again, can you share a screenshot of your event-based action?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Please don't be confuse. We three are from same team
We have implemented script in below event based post-function.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I was actually more interested in the configuration of the event-based action itself... Can you share a screenshot of that?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
@mahammad rafi you need too create an event-based action (which is a JMWE feature), the script I provided will not work with scriptrunner.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Even if I run JMWE Event based actions also script is working as same like working above. There is no difference between direct post-function and JMWE event based action listener.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
An event-based action will run every time the source field (Viewers) is modified, unlike a post-function on a transition.
Can you share the screenshot of your event-based action?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Find screen shots of JMWE Event based action.
So as disussed in above conversation, Can you Please check adding a user initially and adding 2nd user after a min and updating the field in your system, So you can have a clear picture
Regards
Vinodh A
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @Vinodh ,
in "Event", you need to pick "Issue Field Value Changed", and then pick the Viewers field under "Fields to monitor".
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.