Sync cascading field

Originally asked by Vimalraj Rangasamy on 01 July 2021 (original question)


I’m trying to sync cascading fields. I tried hard coding as below, but it did not work.

OEM.issue.customFields.“OEM Test Found In”?.value = “Development”

Also, I have issues with multi select field sync. Kindly request assistance.


Comments:

Ariel Aguilar commented on 01 July 2021

Hi Vimalraj,

We understand you are using a scripted or visual connection? With your piece of code, you are assigning a default value to the local custom field, in this case the value set is “Development”.

Please indicate, what Jira or instances do you have? Are you trying to sync a cascade custom field with another cascade custom field? Please indicate the same for the multi select field sync question.

Kind regards,

Ariel

Answer by Vimalraj Rangasamy on 13 July 2021

Hello Ariel,

I’m trying to set default value to start with. However, i’m getting below error

def DARparent = nodeHelper.getOption(issue, “Test Found In”, “Development”)
issue.customFields.“Test Found In”.value = nodeHelper.getCascadingSelect(
DARparent,
DARparent.childOptions.find

{it.value == “Feature Development”}
)

def OEMparent = nodeHelper.getOption(issue, “OEM Test Found In”, “Development”)
issue.customFields.“OEM Test Found In”.value = nodeHelper.getCascadingSelect(
OEMparent,
OEMparent.childOptions.find{it.value == “Feature Development”}

)

ERROR:
NullPointerException: Cannot get property ‘childOptions’ on null object

Please assist.


Answer by Vimalraj Rangasamy on 09 July 2021

Hi Ariel,

I’m trying sync between to projects in a single instance. Please confirm how it can be managed with above snippet.

Thanks


Answer by Vimalraj Rangasamy on 02 July 2021

Hello Ariel,

We have Jira server instance and i’m trying to sync between 2 issue types within same Jira server instance. I was trying to sync between 2 cascading fields.

DAR.issue.customFields.“Test Found In”?.value = OEM.issue.customFields.“OEM Test Found In”.value?.value

Both “Test Found In” and “OEM Test Found In” are cascading fields.

For Multi select field, I was trying to sync between 2 multi select fields

DAR.issue.customFields.“Affected Programs”.value = OEM.issue.customFields.“OEM Affected Programs”.value?.value

Both “Affected Programs” and “OEM Affected Programs” are multi select fields.

Please assist. Thanks.


Comments:

Ariel Aguilar commented on 08 July 2021

Hi Vimalraj,

You may want to try adding the following snippet for cascade select list for visual connection script:

if (executionInstanceName == "OEM") {
// issue is from "OEM", replica is from "DAR"
//In the script you may also replace the issue variable with OEM.issue and replica with DAR.issue

def sourceOption1 = DAR.issue.customFields."Test Found In"?.value?.parent?.value
def sourceOption2 = DAR.issue.customFields."Test Found In"?.value?.child?.value
 
def option1 = nodeHelper.getOption(
  issue,
  "OEM Test Found In",
  sourceOption1
)
def option2 = option1.childOptions.find{it.value == sourceOption2}
if ( option1 != null && (sourceOption2 == null || option2 != null)) {
  OEM.issue.customFields."OEM Test Found In"?.value = nodeHelper.getCascadingSelect(
              option1,
              option2
  )
} else if (sourceOption1 == null) {
  OEM.issue.customFields."OEM Test Found In"?.value = null
}
}

If you require more information, please refer to: https://docs.idalko.com/exalate/x/bwSOAQ

Let me know if this works for you.

Kind regards,

Ariel