I want to write a custom field version picker (release_version_int).
But I continuous get the following error:
<Error>
java.lang.ClassCastException: com.atlassian.jira.project.version.VersionImpl cannot be cast to java.util.Collection at com.atlassian.jira.issue.customfields.impl.AbstractMultiCFType.createValue(AbstractMultiCFType.java:39) at com.atlassian.jira.issue.fields.ImmutableCustomField.createValue(ImmutableCustomField.java:693) at com.atlassian.jira.issue.fields.ImmutableCustomField.updateValue(ImmutableCustomField.java:410) at com.atlassian.jira.issue.fields.ImmutableCustomField.updateValue(ImmutableCustomField.java:396) at com.atlassian.jira.issue.fields.OrderableField$updateValue.call(Unknown Source) at Script227.run(Script227.groovy:34)
</Error>
I used the following code
<code>
import com.atlassian.jira.component.ComponentAccessor;
import com.atlassian.jira.issue.MutableIssue;
import com.atlassian.jira.issue.util.DefaultIssueChangeHolder
import com.atlassian.jira.issue.CustomFieldManager
import com.atlassian.jira.workflow.JiraWorkflow
import com.atlassian.jira.issue.Issue
import com.atlassian.jira.issue.IssueManager;
import com.atlassian.jira.issue.ModifiedValue
import com.atlassian.jira.issue.CustomFieldManager;
import com.atlassian.jira.issue.fields.CustomField;
import com.atlassian.jira.ComponentManager;
// Retrieve issue ID => Only for debugging in console
def issueManager = ComponentAccessor.getIssueManager();
MutableIssue issue = issueManager.getIssueObject("CV-318");
// Get stored version information
def relVersion = ComponentAccessor.getCustomFieldManager().getCustomFieldObjects(issue).find {it.name == 'release_version'};
def newVersion = issue.getCustomFieldValue(relVersion);
// Get release_version_int object
def relVersion_int = ComponentAccessor.getCustomFieldManager().getCustomFieldObjects(issue).find {it.name == 'release_version_int'};
// get project id
def projectId = issue.getProjectObject().getId();
// Get version
def version = ComponentAccessor.getVersionManager().getVersion(projectId, newVersion);
// Store version in the release_version_int => Required for linking
issue.setCustomFieldValue(relVersion_int, version);
issueChangeHolder = new DefaultIssueChangeHolder();
relVersion_int.updateValue(null, issue, new ModifiedValue("", issue.getCustomFieldValue(relVersion_int)), issueChangeHolder);
issue.store();
def newVersion_int = issue.getCustomFieldValue(relVersion_int);
</code>
Any suggestions?
What is line 34 in your script?
The update function:
relVersion_int.updateValue(null, issue, new ModifiedValue("", issue.getCustomFieldValue(relVersion_int)), issueChangeHolder);
It looks that it is not possible to update an version picker this way.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Try to write like this
relVersion_int.updateValue(null, issue, new ModifiedValue("", [issue.getCustomFieldValue(relVersion_int)]), issueChangeHolder);
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.
If my answer hepled you, kindly accept my answer so that other people could find this answer, if they have a similair question
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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.