Questions for Confluence license has expired.

Please purchase a new license to continue using Questions for Confluence.

Synchronize multi-option checkbox to Organization

 
1
0
-1

Hi,

I'm looking for a way to synchronize a multi-option checkbox to the helpdesk's Organizations field.


This article describes how to sync from the Organizations field to a text field, but not how to sync the other way around. https://docs.idalko.com/exalate/display/ED/How+to+sync+%27Organization+Names%27+to+the+text+custom+field


I also know how to sync the Organization names to a multi-option checkbox, but I don't know how to populate changes from that checkbox back to the Organization field. This is how I synchronise Organization to custom field called Kunden (multi-option checkbox)

Outgoing

final def textFieldCfName = "Organisationen" 
def localOptionValue = issue.customFields[textFieldCfName]?.value if (localOptionValue == null) { throw new com.exalate.api.exception.IssueTrackerException( "Can not synchronize "+textFieldCfName+"to destination jira since there is no value set for issue"+ issueKey.URN +"`("+issueKey.id+")") } 


Incoming

// Check all organizations 
def nygSelectListCfName = "Kunden" 
def cfm = ComponentAccessor.getCustomFieldManager() 
def om = ComponentAccessor.getOptionsManager() 
def remoteOptionValues = replica.customKeys."Organizations" 
def cf = cfm.getCustomFieldObjectsByName(nygSelectListCfName).find() 
def fCfg = cf.getRelevantConfig(IssueContext.GLOBAL) 
def localOptions = om.getOptions(fCfg) 

// Make sure all options are available 
remoteOptionValues.eachWithIndex { orgName, i -> if (!localOptions.any { option -> option.value == orgName }) { om.createOption(fCfg, null, 0L, orgName) } } issue.customFields."Kunden".value = nodeHelper.getOptions(issue, "Kunden", remoteOptionValues) 


Hopefully, someone can help,

Paul

    CommentAdd your comment...

    5 answers

    1.  
      1
      0
      -1

      Thanks for all your contribution. This is how I finally solved it:


      Outgoing

      replica.customFields."Kunden" = issue.customFields."Kunden"

      Incomming

      def organisations = replica.customFields."Kunden".value?.collect{
                  a -> a.value
              }
      issue.customFields."Organisationen".value = organisations
        CommentAdd your comment...
      1.  
        1
        0
        -1

        Another question on this topic.

        From JIRA, we have a Select list custom field on a screen when we Exalate to JSM.
        We select an 'Organization' on this screen upon Exalation, the issue then gets Synced in JSM.

        We want this Organization we select to be populated on the JSM ticket, this should go to the Organization custom list on JSM, which is managed by Insight. I think the complication potentially comes from the fact that the Organization list is managed by Insight.

        At the moment, the Organization field on the JSM ticket is blank. You can type in an Organization in this field and it will populate.

        This is what we have in our JIRA Connections outgoing script:

        replica.customFields."Organizations" = issue.customFields."Organizations"

        And this under our JSM incoming script:

        issue.customFields.Organizations?.value = replica.customFields.Organizations.value?.collect { org -> org?.organizationName }?.findAll()


        Hope this helps.


        1. Francis Martens (Exalate)

          Hi Roy Chapman 

          Can you detail out what is not working at the moment.  Is the organisation field not populating when doing an incoming sync?

        2. Samuel Carter

          Francis Martens (Exalate) Correct, the organization field is blank. Organization should be populated with the information from the select list on the previous screen.

        3. Francis Martens (Exalate)

          Hi Samuel Carter 

          Can you check if the field value assigned to the organizations field is what it should be.
          You can do 2 actions

          a) check out the right hand side calculated value by doing

          def targetOrg = replica.customFields.Organizations.value?.collect { org -> org?.organizationName }?.findAll()
          debug.error("Targetorg = ${targetOrg}")


          When a sync transaction is triggered, an error will be raised containing the targetOrg - is it what you expect

          b) Check out what value can be assigned to Organizations by hard coding something

          I believe Organizations is an array, so you could try something like

          issue.customFields.Organizations?.value = [ "Google", "Apple" ]



          Give it a try.

        4. Samuel Carter

          Hi Francis,


          Thanks for your suggestion and apologies for the delay in getting back to you. 

          Please see below for results of each solution:


          a) Returns the following error 'Cannot get property 'value' on null object'

          b) When I put this in, it will successfully assign ALL the values which are included in the array, so Organizations field on JSM has 'Apple', Google' and 'Microsoft' assigned to it. 


          Thanks and regards,


          Sam

        5. Francis Martens (Exalate)

          Hi Sam,


          Now it is my turn to be apological for the late reply. 


          a) it means that issue.customFields.Organizations is null - is this to be expected?
          b) Should Microsoft not be part of it?


        6. Francis Martens (Exalate)

          From Roy Chapman 


          I have played with the debugging.

          Previously the debug read


          def organisations = replica.customFields."Organizations".value?.collect{
                      a -> a.value
                  }
          debug.error("Targetorg = ${organisations}")



          And generated

          Targetorg = []



          I have changed to read


          def organisations = replica.customFields."Organizations".value?.collect{
                      a -> a.value
                  }
          
          def Royorganisations = replica.customFields."Organizations"
          debug.error("Targetorg = ${Royorganisations}")


          And get this debug.

          Targetorg = com.exalate.basic.domain.hubobject.v1.BasicHubCustomField@8ddb1275



          What does this mean? Does this mean that a value is coming across? If so, where is the value? (I selected TAP as the value)

        7. Francis Martens (Exalate)

          Hi Roy Chapman 


          com.exalate.basic.domain.hubobject.v1.BasicHubCustomField@8ddb1275

          is how groovy denotes an object. The class is BasicHubCustomField and its address is ddb1275


          The reason why you get this, is because you assign the customField to the variable Royorganisations

          def Royorganisations = replica.customFields."Organizations"


          Note that this has nothing to do with the collect operation performed on replica.customFields."Organizations"
          That result is assigned to the variable 'organisations'

          I would rather to

          debug.error("Targetorg = ${organisations}"


          And see what gives.

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

        Hi

        add Davis symbol "?"

        issue.customFields."Organisationen"?.value = replica.customKeys?."Kunden".value

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

          Hi,


          i have a similar challenge;

          1. sync a custom field text to Organization

          2. sync a single select option to Organization


          Does anyone have an idea how this can be done?


          Many thanks in advance

          Cristina

          1. Cristina Mogos

            Hi Francis,


            the solution provided in Exalate documentation works fine when sync goes from Jira Service Desk to Jira SW (Custom Text field).


            i need the other way around now, i have Custom text filed value → JSD Organization; respectively Single select → JSD Organization.


            Many thanks

            Cristina

          2. Francis Martens (Exalate)

            Hi Cristina Mogos

            I thought that a video might help showing how organization does work in my case.  


            But maybe I'm not fully grasping the problem so let me know.

          3. Cristina Mogos

            Hi Francis,


            Thank you very much for the video.I will try to explain more about the Case.

            There are 2 Jira instances : 1 Jira Service Desk (JSD) and one Jira Software (JSW). In JSD there is the  system field Organization. In JSW there is no system field Organization, and we use a custom field for that (Custom field text or single select, depending on the project).

            From JSD to JSW the sync works fine, as you also explained in the video.

            From JSW to JSD i did not find a way to do it; from Text field to Organization ; from single select to Organization.


            hope it is more clear.


            thank you very very much for your time

            Cristina




          4. Francis Martens (Exalate)

            The video highlighted how you can set the organizations in the JSD project.  Apparently not clear enough (smile)
            Anyway - try following


            a) in the incoming sync on the JSD side add following code

            issue.customFields.Organizations.value = ["Organization Name1", "Organization Name2"]

            b) Ensure that both organizations exist in the JSD configuration
            c) Sync a change from JSW to JSD

            d) See if the organizations have been set.


            Next would be to develop a mapping between the select list and the organizations field.  If above fails - let me know.

          5. Cristina Mogos

            Hi Francis,


            it works as you mentioned. yeyyyy (smile)


            Thank you,

            Cristina

          6. Cristina Mogos


            Hi Francis,

            I'm back again...

            Now i can create an issued from JSW to JSD in the right organization. Still, JSD users in that organization do not see the issue. I assume is because the issue has to be "shared with organization". How do i enforce this after issue creation (via Exalate)?


            (shall i open a different queue for this question please let me know.)


            Best and thanks

            Cristina


          7. Francis Martens (Exalate)

            Yes - please (open a new question)

          8. Cristina Mogos

            done

            Thank you for all your support

            Cristina

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

          Hi Paul Schmidt

          You lost me here. 


          On left you have a checkbox customfield, which contains organisation names

          On right, you would like to select the corresponding organisations based on the values in the left customfield


          Is this correct?


          1. Paul Schmidt

            Hi Francis Martens (Exalate) ,


            Thanks for your quick replay. That's correct.




          2. Francis Martens (Exalate)

            OK - lets take it step by step.

            a) Ensure that the customer information is transmitted correctly from Left to Right

            b) Ensure that it is applied correctly on Right.


            Can you confirm that the information is arriving on right (ie. like an array) .
            Check the remote issues tab for more detail
            (assuming you are on a Jira Server to Jira Server environment)

          3. Paul Schmidt

            I can confirm that the organization names reach the right side as an array

          4. Francis Martens (Exalate)

            Can you try something like



            issue.customFields.Organizations.value = replica.customKeys.Organizations
          5. Paul Schmidt

            I tried the following variants:

            issue.customFields."Organizations".value = replica.customKeys."Kunden"
            issue.customFields.Organizations.value = replica.customKeys."Kunden"


            Both lead to the following exception on the right side (Service Desk) when checking a new item on the left side:

            Cannot set property 'value' on null object

          6. Francis Martens (Exalate)

            Paul Schmidt  - i missed your latest comment.

            Cannot set property 'value' on null object


            It means that Organization cannot be found. Can you confirm the name in the custom field list
            Is this Jira Cloud or Jira Server, and in case of server - what version?
            We will try to reproduce

          7. Paul Schmidt

            Hi Francis Martens (Exalate) ,

            We're running Jira Server 8.11.1 on the left side and 8.5.0 on the right side. Exalate version 5.0.3 on both.


            The field Organizations is called Organisationen in the custom field list due to our German installation.


            I adapted it to the following. Now I don't get an error, but the field is not synchronized.


            Left

            replica.customFields."Kunden" = issue.customFields."Kunden"



            Right

            issue.customFields."Organisationen".value = replica.customKeys."Kunden"




          8. Francis Martens (Exalate)

            Ah - good news.

            You should set the value - can you try?


            issue.customFields."Organisationen".value = replica.customKeys."Kunden".value

            Also make sure that the organisation is available on the target.  It must be exactly the same.

          9. Paul Schmidt

            Hi Francis Martens (Exalate) ,


            When I follow your last suggestion, the following happens:

            • When I set an Organization on the left (whose name does exist on the right), it is not updated on the right (but no error is thrown).
            • When I set no Organization on the left, an error is thrown:
            Script error for issue XXX. Details: Cannot get property 'value' on null object. Error line: Script15.groovy:46 


            Also, I am a little confused: When do I use customKeys and when customFields?

          CommentAdd your comment...