As in summary, the challenge is 

  • Setup a Jira On Premise (A) to Jira On Premise (B) visual mode connection
  • ensure that stories are synced such that the epic relation is respected
    Ie. when Story-A1 is related to Epic-A1, then Story-B1 (the twin of Story-A1) is part of Epic-B1 (the twin epic of Epic-B1


    CommentAdd your comment...

    1 answer


      There are different levels to answer this question

      • First level is that the combination Epic, Story, Subtask is synced correctly
      • Second level is that the whole Epic, with all its stories, and subtasks are synced in one go
      • Third level is to have this functionality works bidirectionally
      • Fourth level is to have it on board level, including sprints and all that jazz

      This answer will focus on the first level:

      • Sync an epic correctly (epic name is mandatory)
      • Whenever a story is synced, ensure that the epic link is set correctly
      • Whenever a subtask is synced, ensure that the parent is set correctly

      All of this needs to work on a visual mode connection

      Assume now for a moment that you have setup a visual connection 'a' to 'b' (a and b are the short names which you define when setting up the conenction)

      Apart from configuring standard fields, you will have to define a script rule to ensure that the issue relations (Story to Epic, Subtask to parent) are being respected.

      As there is currently no graphical rule allowing to configure this behaviour. you will have to revert to the scripted rule

      And in the script enter the code as detailed here

      Some explanation

      • Line 1
        Apply the logic on side 'b' 
      • Line 3 and line 4
        if the incoming sync is an epic, ensure that the epic name is set correctly to the epic name on the source
      • Line 7
        Check if the incoming sync is about a subtask. It will be the case because the parentId is set.
        (psst - this is specific for jira-jira. ado-Jira is a bit different)

      • Line 10-12
        In case that the incoming sync is about a subtask, calculate the twin parent, and set it accordingly

      • Line 18-20
        In the case of a story, set the epic link

      There is a flaw in the example above, but we leave it as an exercise to the reader to locate the flaw in the logic. 
      Hint - what happens with issues not part of an epic.

      Next up - if time allows - we will focus on level 2 of the epic sync case

      1. Francis Martens (iDalko)

        There is some doubt that this configuration works.
        Therefore a video

        Note the examples are examples and not full implementations

      2. Wesley Adams

        Hi Francis Martens (iDalko), thanks for the code you provided here. I am getting an error when applying it that states, "MissingPropertyException: No such property: urn for class: com.google.gson.JsonPrimitiveCheck" 

        I have included my code below just to make sure my syntax or where I have each instance is not causing an issue. Per the comments at the top of the visual mode scripting box I have used the on["""Instance Name Here"""] format in my code to reference the remote and local sides of my connection. Could you let me know how to resolve this error? 

        if (executionInstanceName == "Remote Instance Name") {
            if (on["""Remote Instance Name"""].issue.type.name == "Epic") {
                on["""Remote Instance Name"""].issue.customFields."Epic Name"?.value = on["""Local Instance Name"""].issue.customFields."Epic Name"?.value
            } else {
                if (on["""Local Instance Name"""].issue."parentId")  {
                    // this is a subtask - set the local parent it
                    Long remoteParentId = on["""Local Instance Name"""].issue.parentId as Long
                    Long localParentId = nodeHelper.getLocalIssueKeyFromRemoteId(remoteParentId, "issue").id
                    on["""Remote Instance Name"""].issue.parentId = localParentId
                } else {
                    // set the epic link custom field, such that it points to the twin epic of the parent of the source
                    def remoteEpicIssueKey = on["""Local Instance Name"""].issue.customFields."Epic Link"?.value?.urn
                    on["""Remote Instance Name"""].issue.customFields."Epic Link".value = nodeHelper.getLocalIssueKeyFromRemoteUrn(remoteEpicIssueKey, "issue")
      3. Francis Martens (iDalko)

        Can you inspect the value of

        on["""Local Instance Name"""].issue.customFields."Epic Link"?.value

        by using something like

        debug.error("epic link contains ${on["""Local Instance Name"""].issue.customFields."Epic Link"?.value?.properties}")

        PS.  if your shortnames are names without spaces, you can use the more convenient approach to name the objects

        target.issue.customFields."Epic Link"?.value

        It makes the code more readable.

      4. Wesley Adams

        Thanks Francis Martens (iDalko) , could you clarify where in the script I provided the suggested code debug.error("epic link contains ${on["""Local Instance Name"""].issue.customFields."Epic Link"?.value?.properties}") would be best entered? I am getting syntax issues when inserting it so it is difficult to tell where it would be best to place it. 

        Also, I definitely agree with the shortname suggestions and was thinking the same thing earlier. I am not seeing a place where I can rename the shortnames after establishing the connection. Do you know if there is a way I can rename each side so I do not have to establish a whole new connection in order to change the name of each side?

      5. Wesley Adams

        Francis Martens (iDalko) Does this script require any specific setup before it will be able to run? For instance, do I need to do anything involving uploading external scripts to a library related to our Jira Data Center instance? 

      6. Wesley Adams

        I tried adding the debug example you provided after the last line of code but the error message did not change.

      CommentAdd your comment...