Hi,
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.security.roles.ProjectRoleManager;
import com.atlassian.jira.project.Project;
import com.atlassian.jira.project.ProjectManager;
import com.atlassian.jira.security.roles.ProjectRole;
import com.atlassian.jira.security.roles.ProjectRoleActors;
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) {
userList.add(components?.first()?.componentLead)
}
//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
issueManager.updateIssue(user,issue,EventDispatchOption.ISSUE_UPDATED,true);
But I don't have enough experience to implement it on Cloud.
Can someone help with the translation? Any suggestions?