You're on your way to the next level! Join the Kudos program to earn points and save your progress.
Level 1: Seed
25 / 150 points
Next: Root
1 badge earned
Challenges come and go, but your rewards stay with you. Do more to earn more!
What goes around comes around! Share the love by gifting kudos to your peers.
Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!
Join now to unlock these features and more
Hi,
I want to copy FixVersion/s field to custom field Fix Version (Single version picker).
I assisted by this post and rewrite the script mentioned in here: https://community.atlassian.com/t5/Jira-questions/Copy-Affects-Version-and-Fix-Version-values-to-new-Version/qaq-p/127058 (Jeremy code).
when i running this code on the script console in script runner i get the next error:
2018-04-17 12:53:56,645 WARN [common.UserScriptEndpoint]: Script console script failed: java.lang.NullPointerException: Cannot invoke method getId() on null object at Script12.run(Script12.groovy:21
what am I missing here?
This is the code:
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.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;
IssueManager issueManager = ComponentAccessor.getIssueManager();
ProjectManager projectManager = ComponentAccessor.getProjectManager();
CustomFieldManager customFieldManager = ComponentAccessor.getCustomFieldManager();
CustomField nvcf = customFieldManager.getCustomFieldObjectByName("Fix Version"); // Fix Version Custom Field
Project project = projectManager.getProjectByCurrentKey("PROC");
Collection<Long> projectIssueIds = issueManager.getIssueIdsForProject(project.getId());
projectIssueIds.each {
Issue issue = issueManager.getIssueObject(it);
Object fixVersions = issue.getFixVersions();
Object newFieldVersions = issue.getCustomFieldValue(nvcf);
issue.setCustomFieldValue(nvcf,fixVersions);
issueManager.updateIssue(ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser(), issue, EventDispatchOption.ISSUE_UPDATED, false);
}
The system field 'Fix Version/s' is multi-version.
Try to change your custom field to be Version Picker (multiple versions).
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.