This article shows how to synchronize a custom field of type cascading select list.

Cascading select field allows to specify values for the list options. The value in the cascading select field is of type cascading and consists of two dependent options: parent value and child value

Exalate uses following helper methods to sync cascading select fields:


You sync cascading select list option values in different ways: 

Cascading select to cascading select

It's possible that option values don't match on source and destination sides. 

There are different ways to handle this. If the option value does not exist on the receiving side Exalate can do following:

    • don't sync 
    • throw an error (helps to debug, add value to fix the error)
    • check if at least one value exists and sync only that value
    • create a value with the help of external scripts
  • option values match

    Cascading selectA - a cascading select field on the destination side; Cascading selectB - a cascading select field on the source side

    //check if at least one option value exists and sync only existing values
    if (nodeHelper.getOption(
    	    issue, 
    	    "Cascading selectA", 
    	    replica.customFields."Cascading selectB".value.parent.value
    	  ) != null && 
    	nodeHelper.getOption(
    	    issue, 
    	    "Cascading selectA", 
    	    replica.customFields."Cascading selectB".value.child.value
    	  ) != null) {
    		issue.customFields."Cascading selectA"?.value = nodeHelper.getCascadingSelect(
                        nodeHelper.getOption(
    		                issue, 
    		                "Cascading selectA", 
    		                replica.customFields."Cascading selectB"?.value?.parent?.value
    	                 ),
                         nodeHelper.getOption(
    		                issue, 
    		                "Cascading select",
    		                replica.customFields."Cascading selectB"?.value?.child?.value
    	                  )
            )
    }

Set default cascading select list values manually

You can set default cascading select values using nodeHelper.getCascadingSelect method.

There're multiple ways to set default values:

Cascading selectA - cascading select field name on your side;

issue.customFields."Cascading selectA".value = nodeHelper.getCascadingSelect(
       nodeHelper.getOption(issue, "Cascading selectA", "Hobby"), 
       nodeHelper.getOption(issue, "Cascading selectA", "Running")
 )

Override values

Override parent and child values

Cascading selectA - cascading select field name on your side; Cascading selectB - cascading select field name on the source side; 

issue.customFields."Cascading selectA"?.value = nodeHelper.getCascadingSelect(
    nodeHelper.getOption(
		issue, 
		"Cascading selectA", 
		replica.customFields."Cascading selectB"?.value?.parent?.value
	),
    nodeHelper.getOption(
		issue, 
		"Cascading selectA",
		replica.customFields."Cascading selectB"?.value?.child?.value
	)
 )

Override only the parent value

Cascading selectA - cascading select field name on your side; Cascading selectB - cascading select field name on the source side; 

issue.customFields."Cascading selectA".value.parent = nodeHelper.getOption(
	issue, 
	"Cascading selectA", 
	replica.customFields."Cascading selectB"?.value?.parent?.value
)

Override only the child value

Cascading selectA - cascading select field name on your side; Cascading selectB - cascading select field name on the source side; 

issue.customFields."Cascading selectA".value.child = nodeHelper.getOption(
	issue, 
	"Cascading selectA", 
	replica.customFields."Cascading selectB"?.value?.child?.value
)


Sync Cascading select options to text field

Exalate allows to extract the received option values from the cascading select to a text field. More details.


See also

How to synchronize custom fields