VersionCFType custom Field not getting supported

Hello Team,
We are trying to create test case with Version Picker [ Single Version] using Importer.
Let me explain you with the screenshot.
Step 1. Create the versions .

Step 2- We try to import below file.

Step 3 - We match the fields

Step 4- We try to import, below are the findings when we try to import

Step 5- Since entry.getValue() is of type SingleValueMap

else if(customFieldType instanceof VersionCFType){
								issueInputParameters.addCustomFieldValue(entry.getKey(), "v1");
							}
							else {
                                issueInputParameters.addCustomFieldValue(entry.getKey(),((IssueImporterServiceImpl.SingleValueMap)entry.getValue()).getValue());
                            }

I have specifically written for type VersionCFType and even tried to hardcode with issueInputParameters.addCustomFieldValue(entry.getKey(), “v1”);
since ((IssueImporterServiceImpl.SingleValueMap)entry.getValue()).getValue()); was not working.
Still it throws error like this

Please help, how to get the value of it so that it works.

Internally when i debugged inside atlassian own class , it fails after validateCreateIssueFields()

this.issueCreationHelperBean.validateCreateIssueFields(new JiraServiceContextImpl(user, errorCollection), providedFields, issue, fieldScreenRenderer, new OperationContextImpl(IssueOperations.CREATE_ISSUE_OPERATION, fieldValuesHolder), issueInputParameters, i18n);
        if (!errorCollection.hasAnyErrors()) {
            this.issueCreationHelperBean.updateIssueFromFieldValuesHolder(fieldScreenRenderer, issue, fieldValuesHolder);
        }

Please help how to handle this case. It will be of great help for us.

Hi @RaghunandanTata,
you get the Exception "version with id “v1” does not exist because VersionCFType do not accept names like “v1”. It only accept the numeric Version ID (e.g., 10001) as a string.

Thats why this is not working:

issueInputParameters.addCustomFieldValue(entry.getKey(), "v1");

You have to convert the name to id:

String versionName = "v1";  // This could come from your SingleValueMap
Version version = versionManager.getVersionByName(project, versionName);

if (version != null) {
    issueInputParameters.addCustomFieldValue(entry.getKey(), version.getId().toString());
} else {
    throw new IllegalArgumentException("Version with name '" + versionName + "' does not exist.");
}

Let me know if it helps. :slight_smile:

Cheers,
Daniel

1 Like