Is it possible to sync "Database Picker Custom Field" from Scriptrunner?

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)


Answer by Dmitrij POPOV on 05 November 2021

Hello David Henriksson ,

Could you please give more details on your question?

  • Why are you using Database Picker Custom Field (DPCF) value search instead of passing the existing “static” value from the issue?
  • Does your DPCF is using the same DB as your Jira instance?
  • If not: Does your DPCF’s on the both Jira instances use the same DB?