Confluence has been updated to ver 6.15.9. In case of any troubles, please contact infra team.

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...

    2 answers

    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 (iDalko)

        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 (iDalko)

        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 (iDalko)

        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 (iDalko) ,


        Thanks for your quick replay. That's correct.




      2. Francis Martens (iDalko)

        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 (iDalko)

        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 (iDalko)

        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 (iDalko) ,

        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 (iDalko)

        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.

      CommentAdd your comment...