1
0
-1
I would like to synchronize a cascading jira field to Zendesk and specific in two select lists. If it is possible?
    CommentAdd your comment...

    3 answers

    1.  
      1
      0
      -1

      The final configuration that worked for receiving the child values from different fields depending on the parent value chosen was the following:


      String parentValue = replica.customFields."category"?.value?.value //zendesk select list
      
      def childValue;
      if (parentValue == "a") {
      	childValue = replica.customFields."A SUBCATEGORIES"?.value?.value //zendesk select list
      }
      if (parentValue == "b") {
      	childValue = replica.customFields."B SUBCATEGORIES"?.value?.value //zendesk select list
      }
      
      if (parentValue == "c") {
      	childValue = replica.customFields."C SUBCATEGORIES"?.value?.value //zendesk select list
      }
      
      def categoryMapping = [mapping... ]
      
      def parent = nodeHelper.getOption(
      	issue,
      	"Categories/Sub-categories", //cascading field jira
      	categoryMapping[parentValue]
      )
      
      def child = parent.childOptions.find
      
      {it.value == categoryMapping[childValue]}
      if ( parent != null && (childValue == null || child != null)) {
      	issue.customFields."Categories/Sub-categories"?.value = nodeHelper.getCascadingSelect(
      	parent,
      	child
      	)
      } else if (parentValue == null) {
      	issue.customFields."Categories/Sub-categories"?.value = null
      }
        CommentAdd your comment...
      1.  
        1
        0
        -1

        Can i use this script also from Zendesk to Jira? for example, i would like to synchronize two select lists from Zendesk to Cascading field on Jira. 

        1. André Leroy-Beaulieu Castro

          Hi Christos, 


          In that case let's say your two Zendesk fields are "Select List 1" and "Select List 2", and your Jira field is "Cascading Select":


          Outgoing Zendesk:

          replica.customFields."Select List 1" = issue.customFields."Select List 1"
          replica.customFields."Select List 2" = issue.customFields."Select List 2"


          Incoming Jira:

          String parentValue = replica.customFields."Select List 1"?.value?.value
          String childValue = replica.customFields."Select List 2"?.value?.value
          
          def parent = nodeHelper.getOption(
                  issue,
                  "Cascading Select",
                  parentValue
          )
          def child = parent.childOptions.find{it.value == childValue}
          if ( parent != null && (childValue == null || child != null)) {
              issue.customFields."Cascading Select"?.value = nodeHelper.getCascadingSelect(
                      parent,
                      child
              )
          } else if (parentValue == null) {
              issue.customFields."Cascading Select"?.value = null
          }

          Thanks,


          André

        CommentAdd your comment...
      2.  
        1
        0
        -1

        Hi! You can extract the child and parent values of the Jira cascading field from zendesk like this:


        //Incoming script on zendesk
        def cascadingValue = replica.customFields."Cascading Jira Field"?.value
        
        if(cascadingValue){
          def parentValue =  cascadingValue.parent?.value //This is a String value
          def childValue = cascadingValue.child?.value //This is a String value
          /*
          from here, you can set directly to a zendesk field or map to a different value
          if(parentValue)
            issue.customFields."Zendesk Parent Field".value = parentValue
          
          or
        
          def valueMap = ["Jira V": "Zendesk V"]
          if(childValue)
            issue.customFields."Zendesk Child Field".value = valueMap[childValue]
        
        
          */
        }
        
        
        


        Let me know if this makes sense.


          CommentAdd your comment...