I have added a post function to a transition in my workflow to clone an issue. I want to set the component of that new issue in the `Additional issue actions` section but I can't figure out how to do it. I have the string name of the component but it seems you can't set it by string. I imagine there's a pretty straightforward way to do this, but I can't figure it out!
Hello Sandrine,
I hope you are having a nice day.
As you can see in this documentation, you can use the following code to set Affects Versions, Fix Versions or Components:
ComponentManager componentManager = ComponentManager.getInstance()
User remoteUser = componentManager.getJiraAuthenticationContext().getUser()
MutableIssue issue = componentManager.getIssueManager().getIssueObject(
"DTT-1757"
)
Project project = issue.getProjectObject()
Version version = componentManager.getVersionManager().getVersion(project.getId(),
"1.2"
)
ProjectComponent component = componentManager.getProjectComponentManager().findByComponentName(project.getId(),
"MyComponent"
)
issue.setFixVersions([version])
issue.setComponents([component.getGenericValue()])
Map actionParams = EasyMap.build(
"issue"
, issue.getGenericValue(),
"issueObject"
, issue,
"remoteUser"
, remoteUser,
"dispatchEvent"
, Boolean.FALSE);
ActionResult aResult = CoreFactory.getActionDispatcher().execute(ActionNames.ISSUE_UPDATE, actionParams);
// check aResult
Let me know if this example helps.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.