Hi,
I'm facing a problem where I need to add label to each newly created issue in exact project. Problem is that we don't want to clone workflow, as we are using same in each project.
So I wanted to add post-function in workflow with ScriptRunner script as following
import java.util.Set import com.atlassian.jira.component.ComponentAccessor import com.atlassian.jira.project.Project import com.atlassian.jira.issue.label.* import com.atlassian.jira.security.JiraAuthenticationContext LabelManager labelManager = ComponentAccessor.getComponent(LabelManager.class); JiraAuthenticationContext jiraAuthenticationContext = ComponentAccessor.getJiraAuthenticationContext(); com.atlassian.jira.user.ApplicationUser myUser = jiraAuthenticationContext.getLoggedInUser(); Project myProject = issue.getProjectObject(); if (myProject.getKey() == 'SC') { labelManager.addLabel(myUser, issue.getId(), 'myNewLabel', false); }
I though that issue is already created during post-function, but i'm getting error
2016-08-31 10:27:55,817 ERROR [workflow.ScriptWorkflowFunction]: ************************************************************************************* 2016-08-31 10:27:55,817 ERROR [workflow.ScriptWorkflowFunction]: Script function failed on issue: null, actionId: 1, file: <inline script> com.atlassian.jira.util.dbc.Assertions$NullArgumentException: issueId should not be null! at com.atlassian.jira.util.dbc.Assertions.notNull(Assertions.java:25) at com.atlassian.jira.issue.label.DefaultLabelManager.addLabel(DefaultLabelManager.java:104) at com.atlassian.jira.issue.label.LabelManager$addLabel.call(Unknown Source) at Script99.run(Script99.groovy:16)
Thanks
Community moderators have prevented the ability to post new answers.
Please make sure your post-function is after "Creates the issue originally." post-function, preferably at the end of the list of post-functions.
yep, solved. thx
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.