with JIRA v7.1.9#71013 and JIRA rest API 4.0.0
Scala code:
case class JiraFieldDefinition(id: Long, fullIdForSave: String, typeName: String, itemsTypeIfArray: Option[String])
and then processing for custom fields:
case _ =>
val fieldSchema = customFieldResolver.getId(fieldName)
if (fieldSchema.isDefined) {
val fullIdForSave = fieldSchema.get.fullIdForSave
val valueWithProperJiraType = getConvertedValue(fieldSchema.get, value)
issueInputBuilder.setFieldValue(fullIdForSave, valueWithProperJiraType)
}
def getConvertedValue(fieldSchema: JiraFieldDefinition, value: Any) : Any = {
fieldSchema.typeName match {
case "array" if fieldSchema.itemsTypeIfArray.get == "string" => List(value).asJava
case "array" if fieldSchema.itemsTypeIfArray.get == "option" =>
List(
new CustomFieldOption(fieldSchema.id, null, value.toString, Seq().toIterable.asJava, null)
).asJava
case "number" => ValueTypeResolver.getValueAsFloat(value)
case _ => value
}
}
so, to summarize: this code goes through custom fields. it works fine for a custom "label" where an array of strings is expected. ( case "array" if fieldSchema.itemsTypeIfArray.get == "string" )
but it fails for a custom field called "custom_checkbox_1" with ID 10102 and customId=customfield_10102.
(see the second "case" for array+option).
the error I get is:
ErrorCollection{status=400, errors={customfield_10102=Invalid value '10102' passed for customfield 'custom_checkbox_1'.}, errorMessages=[]}
At the American Academy of Family Physicians, siloed marketing teams faced delays and duplicate work. Kerrie Gottschalk shook things up by moving the department to Jira, streamlining processes, boosting visibility, and sparking stronger collaboration.
Read the story
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.