It's not the same without you
Join the community to find out what other Atlassian users are discussing, debating and creating.
Hi - I'm trying to import data from Redmine into JIRA. After the import, I have a custom field (text) that contains the value for Affects Version. How do I copy this custom field into Affects Version? JIRA support asked me to look into ScriptRunner, bur I'm not seeing how to yet
I think the idea here is that you import the text field as text initially, and then write a script that you can run as a one-off that will read the field on each issue, find (or create) a matching version for it in the project and then set the affects version to it. Then delete the text field as you don't need it any more.
Got it! Instead of using updateIssue, I had to use updateIssueAffectsVersions:
versionManager.updateIssueAffectsVersions(issue, affectsVersions); //issueManager.updateIssue(ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser(), issue, EventDispatchOption.ISSUE_UPDATED, false);
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Nic - I tried your suggestion but am still stuck at setting the affectsVersion field. This is the code I have:
import com.atlassian.jira.ComponentManager; import com.atlassian.jira.component.ComponentAccessor; import com.atlassian.jira.issue.Issue; import com.atlassian.jira.project.version.Version; import com.atlassian.jira.project.version.VersionImpl; import com.atlassian.jira.issue.IssueManager; import com.atlassian.jira.issue.CustomFieldManager; import com.atlassian.jira.issue.fields.CustomField; import com.atlassian.jira.event.type.EventDispatchOption; import com.atlassian.jira.project.Project; import com.atlassian.jira.project.ProjectManager; import java.util.ArrayList; import java.util.Collection; def projectManager = ComponentAccessor.getProjectManager() def issueManager = ComponentAccessor.getIssueManager() def customFieldManager = ComponentAccessor.getCustomFieldManager() def vfi = customFieldManager.getCustomFieldObjectByName("jiramigration_vfi") Project project = projectManager.getProjectByCurrentKey("APPMGR"); Collection<Long> projectIssueIds = issueManager.getIssueIdsForProject(project.getId()); log.warn(" Init2 "); Collection<Version> projVers = project.getVersions(); projVers.each { log.warn(it.getProject()); log.warn(it.getDescription()); log.warn(it.getId()); log.warn(it.getName()); } projectIssueIds.each { Issue issue = issueManager.getIssueObject(it); Collection<Version> affectsVersions = issue.getAffectedVersions(); def cur_vfi = issue.getCustomFieldValue(vfi); String cur_val = cur_vfi.toString(); if (affectsVersions == null || !affectsVersions.size()) { affectsVersions = new ArrayList<Version>(); Version verToLog; projVers.each { if (it.getName() == cur_val) { log.warn(" Match --- " + it.getName() + " " + cur_val); verToLog = it; } } if (verToLog != null) { log.warn(" Ver Name " + verToLog.getName()); affectsVersions.add(verToLog); issueManager.updateIssue(ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser(), issue, EventDispatchOption.ISSUE_UPDATED, false); } } }
The script runs w/o errors, but the issue does not show the affects Versions field populated.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
It started as any story starts, on a normal, rainy day. Admin meets App, and her name was Klok2, and like any first relationship we were both trying to make it work but neither one knew what...
Connect with like-minded Atlassian users at free events near you!
Find a groupConnect with like-minded Atlassian users at free events near you!
Unfortunately there are no AUG chapters near you at the moment.
Start an AUGYou're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.