Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
Deleted user
0 / 0 points
badges earned

Your Points Tracker
  • Global
  • Feed

Badge for your thoughts?

You're enrolled in our new beta rewards program. Join our group to get the inside scoop and share your feedback.

Join group
Give the gift of kudos
You have 0 kudos available to give
Who do you want to recognize?
Why do you want to recognize them?
Great job appreciating your peers!
Check back soon to give more kudos.

Past Kudos Given
No kudos given
You haven't given any kudos yet. Share the love above and you'll see it here.

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

Get the Component Lead and add ScriptRunner Cloud


I'm trying to implement a post-function in ScriptRunner Cloud that gets the Component Lead and set it as Approver, I have that script in SR Server:

import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.bc.projectroles.ProjectRoleService;
import com.atlassian.jira.project.Project;
import com.atlassian.jira.project.ProjectManager;
import com.atlassian.jira.util.ErrorCollection;
import com.atlassian.jira.util.SimpleErrorCollection;
import com.atlassian.jira.user.util.Users
import com.atlassian.jira.issue.CustomFieldManager
import com.atlassian.jira.issue.fields.CustomField
import com.atlassian.jira.issue.IssueManager
import com.atlassian.jira.event.type.EventDispatchOption

def sb = new StringBuffer() //sb is used to send string to logs
//Set the Project Roles readers/objects
ProjectRoleService projectRoleService = (ProjectRoleService) ComponentAccessor.getComponentOfType(ProjectRoleService.class);
ProjectRoleManager projectRoleManager = (ProjectRoleManager) ComponentAccessor.getComponentOfType(ProjectRoleManager.class);
ProjectManager projectManager = ComponentAccessor.getProjectManager();

ErrorCollection ec = new SimpleErrorCollection();
//Create the Global definitions
def issueManager = ComponentAccessor.issueManager
def customFieldManager = ComponentAccessor.customFieldManager
def project
def userPropertyManager = ComponentAccessor.userPropertyManager
//Create the Specific definitions

def userList = new ArrayList();

def components = issue.componentObjects.toList()
if (components) {
//Prepare the field to set the values
CustomField customFieldApprovers = customFieldManager.getCustomFieldObjectByName("Approvers");
//set the value
issue.setCustomFieldValue(customFieldApprovers, userList)
//author of the change
def user = ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser()
//Submit the change

But I don't have enough experience to implement it on Cloud.

Can someone help with the translation? Any suggestions?

1 answer

1 accepted

1 vote
Answer accepted

Hi @Daniel Alonso 

Thank you for the question.

In order for you to get the Component from the issue and by call Get Component API as documented here. To do this you would need the ID of the component which you can get from the components filed on the issue. Then to set the approver field update. 

We in ScriptRunner for Jira Cloud have an example to get the component issue and update it with the Approver field value here. You can use the sample code as a guide to get the result/requirement that you want. 

Hope this will help you.

Thank you.

Kind Regards


Thanks Kate,

I will try that Snippet, is there a way I see more examples? The Library is very limited. Thanks.

Hi @Daniel Alonso 

Yes, we do have other examples that you can refer to as guidance:

Hope this will help with your integration.

Thank you

Kind Regards


Suggest an answer

Log in or Sign up to answer
Site Admin
Community showcase
Published in Marketplace Apps & Integrations

Staying organized with Jira: best practices for a better project management

Project managers know this problem: A “mountain of work” lays in front of you, and you don’t know how and where to tackle them. Different to-dos lie ahead, but just one task after the other can be ha...

254 views 2 1
Read article

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you