How to Sync Elements Connect Custom Fields Value when they are Connected to the Same Database on Jira Cloud

    Introduction

    Note: The new version of the Elements Connect custom field (v5.13.0) does not accept an array of ids as a value. You must convert ids to values.

    This article provides an example of the script which helps to sync the values of the Elements Connect custom field when each side uses different add-on versions.

    Source side

    Add this script to the Data Filter to send nFeed/element custom field's data.

    1 def ndFeedCFName = "nFeed custom field name"
    2 def cfm = com.atlassian.jira.component.ComponentAccessor.getCustomFieldManager()
    3 def cf = cfm.getCustomFieldObject(issue.customFields[ndFeedCFName].id)
    4 def cft = cf.getCustomFieldType()
    5 replica.customKeys[ndFeedCFName] = cft.getStringFromSingularObject(issue.customFields[ndFeedCFName]?.value)

    Destination side

     Incoming sync

    Receive Elements Connect custom field data:

    1 // SYNC NFEED VALUES / ELEMENT CONNECT
    2 ({
    3     def syncNfeed = { String remoteCfName, String cfName->
    4         def cfm = com.atlassian .jira.component.ComponentAccessor.getCustomFieldManager()
    5         def cf = cfm.getCustomFieldObject(issue.customFields[cfName].id)
    6         def cft = cf.getCustomFieldType()
    7        issue.customFields[cfName].value = cft.getSingularObjectFromString(replica.customKeys[remoteCfName])
    8     }
    9     syncNfeed("nFeed remote custom field name","nFeed1 local custom field name")
    10 })()
    11 // END: SYNC NFEED VALUES