How to update a custom field with a project role

Hello, I want to use your plugin to

a) get a member progragmatically from a role into a custom field

b) later assign the issue to the user in the custom field

The role is an own created with only one single Person who should get the ticket in the end. Step b seems easy but I don't get a working.

I tried use post function with: (carefully it's translated from german) "set custom fiel with Content"..
b) first param I selected my field to set
c) second param is my Problem. I want  to get the one Person from my role xxx (per Project). Is there a makro like:

'%%CURRENT_USER%% for role or an Option?

Thanks for help!

1 answer

1 accepted

0 vote
Tarun Sapra Community Champion Jul 20, 2016

I would suggest to use Script Runner in the post function to fetch the user from the role and then use script to update custom field value with the username

import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.user.ApplicationUsers
def projectRoleManager = ComponentAccessor.getComponent(ProjectRoleManager)
def projectRoleId = 10500  // ID of Automatic Watcher project role
def role = projectRoleManager.getProjectRole(projectRoleId)
def actors = projectRoleManager.getProjectRoleActors(role, issue.projectObject)
def usersInRole = actors.getApplicationUsers();

Now update the custom field value as discussed many times in the forumn -

Suggest an answer

Log in or Sign up to answer
Atlassian Community Anniversary

Happy Anniversary, Atlassian Community!

This community is celebrating its one-year anniversary and Atlassian co-founder Mike Cannon-Brookes has all the feels.

Read more
Community showcase
Julia Dillon
Posted Tuesday in Jira

Tell us how your team runs on Jira!

Hey Atlassian Community! Today we are launching a bunch of customer stories about the amazing work teams, like Dropbox and Twilio, are doing with Jira. You can check out the stories here. The thi...

244 views 1 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