2
1
0

Hi,

i have a single drop down field in ZD that i need to sync on the outgoing part.

replica.customFields.fieldname.value= ?

    CommentAdd your comment...

    1 answer

    1.  
      2
      1
      0

      Hi ben friedman


      You're getting pretty good at it


      To answer your question - just use


      replica.customFields.fieldname = issue.customFields.value


      Some more information might be useful.

      Whenever you would need some insight on what the issue and replica object contain, you can always revert to raising an Exception.  This will popup a message on the error list.

      For instance - if you would like to know what the content is of a dropdown 'Mood'

      Add following code to the outgoing sync

      Outgoing sync
      throw new Exception("Mood = ${issue.Mood.properties}")


      Trigger a sync by modifying a zendesk ticket which is under sync.
      This will generate an error (we know - this is not optimal, but we are working on a feature to simplify that workflow)




      The interesting content is

      [value:delighted, class:class com.exalate.basic.domain.hubobject.v1.BasicHubOption, disabled:null, childOptions:null, sequence:null, id:360005162417, parentOption:null]


      Hope this helps

      1. ben friedman

        Hi Francis Martens (Exalate) i think it did.

        i dont have the error on the outgoing side any longer. 

        however, i am seeing an error now on the incoming side. 


        so, to note, on the outgoing side, its a single list field with:

        replica.customFields."pBys" = issue.customFields."Priority reflective of Severity"


        on the receiving side, its:

        issue.customFields."Priority reflective of Severity".value= replica.customFields."pBys".value

        where the custom field is of a single list type. 


        the error i get is:

        Field Field 'labels' cannot be set. It is not on the appropriate screen, or unknown.: labels.


        also, is there something for error exceptions on the incoming side too?

      2. Francis Martens (Exalate)

        Checkout the error message


        Field Field 'labels' cannot be set. It is not on the appropriate screen, or unknown.: labels.


        a) it has nothing to do with the setting of the customField

        b) Probably you have issue.labels = replica.labels and that field is not on the create issue screen


        You can either add the labels field to the issue create screen, or remove that line and retry again

      3. ben friedman

        odd. i had a sync already done before when it was available, but the error just popped up now. i removed the labels and the error was gone.

        Francis Martens (Exalate) still needing your help...

        on the receiving side, i get the error:

        Field Option id 'null' is not valid: customfield_10051.

        this is for line: 

        issue.customFields."Priority reflective of Severity".value= replica.customFields."pBys".value


        i have checked and on the replica on the sending side, pBys.value ="blocking_all". (even though the option in the field itself is 'Blocking ALL')

        on the recieving side the option is called 'Blocking ALL'.


        im not sure why the error is a 'null'. the sending replica is not null.

        and am i using the assignment on the receiving side correctly?

      4. Francis Martens (Exalate)

        Are you sure this is the offending line?
        What happens when you comment it out

        What is customfield_10051 btw.

        Regarding the second topic, you will have to create a mapping to calculate the local value such as


        def optionMapping = [
            // remote_value : local_value
            ...
            "blocking_all" : "Blocking ALL",
            "some_remote_value" : "some_local_value",
             ...
        ]
        
        issue.customFields."Priority reflective of Severity".value = optionMapping[replica.customFields."pBys".value]



        You can be a bit more defensive by using the groovy safety operator <?> and the elvis operator <?:>
        (Look them up)

        def optionMapping = [
            // remote_value : local_value
            ...
            "blocking_all" : "Blocking ALL",
            "some_remote_value" : "some_local_value",
             ...
        ]
        // Default to 'Blocking ALL' in case the custom field is not provided on the replica, or if it has a value which is not in the mapping
        issue.customFields."Priority reflective of Severity".value = optionMapping[replica.customFields."pBys"?.value] ?: "Blocking ALL"



      5. ben friedman

        Francis Martens (Exalate) 

        yes, when i remove that line, there is no error.

        customfield_10051 is a custom drop down field (single list option) named priority reflective of severity.  thanks for the mapping tip.


        i appreciate the help. figured the issue out.

        the outgoing replica had a .value.value where i used only .value in the incoming (which included id and value) and i used the mapping to set the correct text value on the receiving side. 

      6. Francis Martens (Exalate)

        OK - is the configuration set?


      7. Francis Martens (Exalate)

        ben friedman - please mark the question answered - thanks

      CommentAdd your comment...