Originally asked by David Henriksson on 21 October 2021 (original question)
I wonder if it is possible to sync Database Picker Custom Field (multiple options)?
I tried with this but I get an exception:
Source Instance (Outgoing Sync):
String productTypeCFName = "Product Type"
def productTypeCF = customFieldManager.getCustomFieldObject(issue.customFields[productTypeCFName].id)
def productTypeCFT = productTypeCF.getCustomFieldType()
replica.customKeys[productTypeCFName] = productTypeCFT.getStringFromSingularObject(issue.customFields[productTypeCFName]?.value)
Target Instance (Incoming Sync):
({
def syncDbField =
{ String remoteCfName, String cfName-> def cfm = com.atlassian .jira.component.ComponentAccessor.getCustomFieldManager() def cf = cfm.getCustomFieldObject(issue.customFields[cfName].id) def cft = cf.getCustomFieldType() issue.customFields[cfName].value = cft.getSingularObjectFromString(replica.customKeys[remoteCfName]) }
syncDbField("Product Type", "Product Type")
})()
I get this as exception: java.util.ArrayList cannot be cast to java.lang.String
On this line:
replica.customKeys[productTypeCFName] = productTypeCFT.getStringFromSingularObject(issue.customFields[productTypeCFName]?.value)