Questions for Confluence license has expired.

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

How to create a normal issuelink (Local synchronisation)

 
2
1
0
I have a local connection between two Jira Software projects. Whenever an issue is exalated, I would like to have a normal issue link between the twins. How?
    CommentAdd your comment...

    1 answer

    1.  
      2
      1
      0

      The method to create such a link is


      • Ensure that the outgoing message contains the id of the issue under sync

        replica.customKeys.issueId        = issue.id
      • Ensure that during the first sync, the syncBackAfterProcessing is called
        This is necessary because at during the firstSync the issue is not yet created, and the issue.id is required to build a link

        if (firstSync) {
            if(replica.project.key == "HAS"){
               issue.projectKey   = "AN"
               issue.typeName     = nodeHelper.getIssueType(replica.type?.name, issue.projectKey)?.name ?: "Task"
            
            }
            if(replica.project.key == "AN"){
               issue.projectKey   = "HAS"
               issue.typeName     = nodeHelper.getIssueType(replica.type?.name, issue.projectKey)?.name ?: "Task"
        
            }
            syncHelper.syncBackAfterProcessing()
        }



      • Whenever getting an incoming message, ensure that a link is created if not yet existing

        if (!firstSync) {
            
            /***********************************   ISSUE LINK *******************
             * Make sure there is an issue link to the other side
             ********************/
             
            def nserv = com.atlassian.jira.component.ComponentAccessor.getOSGiComponentInstanceOfType(com.exalate.api.node.INodeService.class)
            def proxyUser = nserv?.getProxyUser()
            def ilm = com.atlassian.jira.component.ComponentAccessor.getIssueLinkManager()
            
            def RELATES = 10003L // 10003 is the 'relates' issue link type
                
            Long localId = Long.parseLong(issue.id)
            Long remoteId = Long.parseLong(replica.customKeys.issueId)
            
            // check if the link exists
            def linkExists =  ilm.getInwardLinks(RELATES).find { it.sourceId == remoteId } || 
                              ilm.getOutwardLinks(RELATES).find { it.destinationId == remoteId }
        
            
            
            if (!linkExists) 
                ilm.createIssueLink(localId, remoteId, RELATES, null, proxyUser)
              
        }


      Give it a try

        CommentAdd your comment...