2
1
0

Hi there,


How to show my exalated destination record id in source JQL result.


Let's consider I have project A and Project B.

I have exalated A record and its created B record, but when i using JQL filter for Project A there it shows exalated record ID also(that is B).


Is there any possible way to show my destination exalated ID whenever i exalated source record through scripted field or Listener event to get the key value.


Regards,

Moogambigai G R

    CommentAdd your comment...

    3 answers

    1.  
      1
      0
      -1

      We have created custom fields to gather information about the remote issue and populate it this way:


      //Put the remote ticket URL in the Integration URL field
      issue.customFields."Integration URL".value = remoteIssueUrl
      //Remote ticket number  to Remote ID field
      issue.customFields."Remote ID".value = replica.key
      //Integration App link - name of this connection
      issue.customFields."Integration App Link".value = "XXXXXX" 

      XXX is the connection name and hard coded in the script. 



      1. Moogambigai G R

        Hi Karen Jennings 


        I have tried with Jochim Van Dijck answer, its working fine in one way(A->B) but I have a two way sync.

        A→ Project 1

        B→ Project 2

        When I first exalated A record, its created B record and its checking the condition as per below condition and i am able to see the remote ID in source side immediately after create.

        if (issue.customFields."OEM Sync ID".value == replica.key) {
          // sync all changes, this is not the first sync back
        } else {
          issue.customFields."OEM Sync ID".value = replica.key
        }

        But, if I first exalated record B, the above condition not satisfying its directly goes to else part.


        Regards,

        Moogambigai G R


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

      Hi Moogambigai G R 


      You'll need to create/use a custom field to store the remote issue key. On the destination side, you add the Jira Issue key in the outgoing sync, while on the source side you add the information to the custom field. Example:


      B Side (OUTGOING)
      replica.key = issue.key
      A Side (INCOMING)
      //Change <Remote Issue Key> with the name of your field
      issue.customFields."Remote Issue Key" =  replica.key


      This will populate the field whenever side B has had an update first. If you want side B to send back the Jira key immediately after create, you can add the following to side B's incoming sync at the bottom.

       (info) Make sure your outgoing sync on side B passes the issue key as per code block 1.

      Side B (INCOMING)
      if(firstSync)
      {
          syncHelper.syncBackAfterProcessing()
      }


      Hope this helps

      Kind regards

      Jorden


      1. Moogambigai G R

        Hi Jorden Van Bogaert 


        Thanks for the answers.


        yes, we have tried the above configuration, here we are syncing two projects in same instance and also its a two way sync.


        There we are facing issues, in destination side we are setting default value for some custom fields even though in source side value is different if we put sync back after processing, once record is exalated its again sync back to source and changing all fields.


        so that's why is there any other possible way to get remote key.


        Regards,

        Moogambigai G R

      2. Jorden Van Bogaert

        Hi Moogambigai G R 


        If the fields have different values, and you don't want the values to overwrite the source side, you should simply remove those fields from being send to the other side by removing them from the outgoing sync.


        Or you can alter your incoming sync to only process certain fields and not all.


        If you don't do either of these two, you'll values be overwritten anyways whenever the remote side has any update to tickets.


        Kind regards

        Jorden

      3. Moogambigai G R

        Hi Jorden Van Bogaert 


        Is it possible? whenever I first exalated the issues in source side it should sync back only remote key from destination side, after in same destination record  if i change or update something, source side should be get update?


        Below is the current configuration currently using, I have shared same code only, but we have more fields, please help on this.


        Outgoing Script:
        A->B
        
        if (issue.project.key == "DAR" && issue.typeName == "Defect")
        {
        replica.key            = issue.key
        replica.type           = issue.type
        replica.customFields."10706" = issue.customFields."10706" 
        replica.customFields."10134" = issue.customFields."10134"
        }
        
        B->A
        else if (issue.project.key == "OEM" && issue.typeName == "Acquired Product Defect")
         
        {
        replica.key            = issue.key
        replica.type           = issue.type
        replica.customFields."17002" = issue.customFields."17002"
        replica.customFields."17003" = issue.customFields."17003"
        }
        Incoming Script:
        sync A->B
        if(replica.project.key == "DAR" && replica.type.name == "Defect") //sync A -> B
        {
          issue.projectKey   = "OEM"
          def issueTypeMapping = [
          "Defect" : "Acquired Product Defect"
        ]
         
        issue.typeName = issueTypeMapping[replica.type?.name] ?: "Acquired Product Defect"
        
          issue."17003" = "Alexandra" 
           issue."17002" = replica."10706"
        
        if(firstSync){
          syncHelper.syncBackAfterProcessing()
          
        
        } 
        
        }
        
        sync B->A
        
        
        else if(replica.project.key == "OEM" && replica.type.name == "Acquired Product Defect")  { 
        //sync B -> A
         issue.projectKey   = "DAR"
          
          def issueTypeMapping = [
          "Acquired Product Defect" : "Defect"
        ]
         
        issue.typeName = issueTypeMapping[replica.type?.name] ?: "Defect"
        
          issue."10134" = "Alexandra"
          issue."10706" = replica."17002"
          issue.customFields."OEM Sync ID".value = replica.key
        }

        Regards,

        Moogambigai G R

      4. Jochim Van Dijck

        Hi Moogambigai G R 


        In the incoming sync you can check if the local issue already has this custom field for the external key set, and if it has, sync the incoming changes.

        If the issue does not have the external key, but the replica does, then we know this is the first sync back and we can set the external key custom field, but nothing else.


        In code it could look something like this:

        if (issue.customFields."OEM Sync ID".value == replica.key) {
          // sync all changes, this is not the first sync back
        } else {
          issue.customFields."OEM Sync ID".value = replica.key
        }


        Regards,

        Jochim

      5. Moogambigai G R

        Hi Jochim Van Dijck 


        Yes its working when I first exalated record in source side and its syncing back destination key.

        But when I when created record in destination side and sync to source side, its not working it throws error, there because its not satisfiying with below condition destination incoming sync.


        else if(replica.project.key == "OEM" && replica.type.name == "Acquired Product Defect")//sync B -> A
        { 
        
         issue.projectKey   = "DAR"
          
          def issueTypeMapping = [
          "Acquired Product Defect" : "Defect"
        ]
         
        issue.typeName = issueTypeMapping[replica.type?.name] ?: "Defect"
        
        if (issue.customFields."OEM Sync ID".value == replica.key)
        {
          issue."11030" = replica."17004" //Defect Change Type//OEM Defect Change Type
          issue."10113" = replica."17006" //Customer Severity//OEM Customer Severity
        
        }
        
        else
        {
          issue.customFields."OEM Sync ID".value = replica.key
        }}

        Regards,

        Moogambigai G R


      6. Moogambigai G R

        Hi there,


        Is  there any update?


        Regards,

        Moogambigai G R

      7. Jorden Van Bogaert

        Hi Moogambigai G R 


        You can use if(firstSync) to differentiate the conditions.


        firstSync will be "true" if a local issue does not exist yet. In that case, you probably want to receive all data from the other side, when firstSync is false (local issue already exists), then you want to use the condition as per Jochim's response.


        Hope this helps.

        Kind regards

        Jorden

      8. Moogambigai G R

        Hi Jorden Van Bogaert 


        Can you provide sample configuration to differentiate the condition?


        Regards,

        Moogambigai G R

      9. Jorden Van Bogaert

        Hi Moogambigai G R 


        Looking at Jochim's code, I simply changed first condition to include the firstSync, that should do the trick I think.

        if (issue.customFields."OEM Sync ID".value == replica.key || firstSync) {
          // sync all changes, this is not the first sync back
        } else {
          issue.customFields."OEM Sync ID".value = replica.key
        }
      10. Moogambigai G R

        Hi Jorden Van Bogaert 


        Thanks for you answer,


        We have existing records that also should update with destination key but with above configuration is not possible because only new records its updating. So I have tried below configuration(scripted field (script runner)).


        I am able to see the destination key, but here I changed exalate connection configuration has "Remote link panel" instead of "Sync Panel" only i am to show the destination key.

        Here also we used "sync panel" before but after i changed to "Remote link panel" it only appears for new issues not able to get existing issues. 


        Is there any possible to get the destination record with below configuration instead of using "remote link" configuration.


        import com.atlassian.jira.component.ComponentAccessor
        import com.atlassian.jira.config.properties.APKeys
        import com.atlassian.jira.issue.link.RemoteIssueLinkManager
        import com.atlassian.jira.issue.Issue
        // Get the components
        def issueManager = ComponentAccessor.issueManager
        def issueLinkManager = ComponentAccessor.issueLinkManager
        def remoteIssueLinkManager = ComponentAccessor.getComponent(RemoteIssueLinkManager)
        
        // Define the params to get an issue and filter the issue links by type
        //final issueKey = 'DAR-526120'
        //final issueLinkTypeName = 'Exalated with'
        // Get the issue
        //def issue = issueManager.getIssueByCurrentKey(issueKey)
        
        Issue issue  = issue
         
        issueKey =  issue.getKey()
        /*//def issue = issueManager.getKey()
        // Get the issue links to other issues
        //def issueLinks = issueLinkManager.getOutwardLinks(issue.id)
        //def filteredLinks = issueLinks.findAll { it.issueLinkType.name == issueLinkTypeName}
        
        // Collect the HTML links pointing to the linked issues
        def baseUrl = ComponentAccessor.applicationProperties.getString(APKeys.JIRA_BASEURL)
        def linkedIssuesHtmlLinks = filteredLinks.collect { issueLink ->
            def issueUrl = "${baseUrl}/${issueLink.destinationObject.key}"
            "<a href='${issueUrl}'>${issueLink.destinationObject.key}</a>"
        }*/
        
        // Collect the HTML links pointing to the remote links
        def remoteLinks = remoteIssueLinkManager.getRemoteIssueLinksForIssue(issue)
        def remoteLinksHtml =  remoteLinks.collect {remoteLink ->
            "<a href='${remoteLink.url}'>${remoteLink.title}</a>"
        }
        
        // Display the links
        """<p>
        <ul>
            ${remoteLinksHtml.collect {"<li>${it}</li>" }.join('\n')}
        </ul>"""



        Regards,

        Moogambigai G R

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

      Hallo Moogambigai G R,


      may be this link can help:


      https://docs.idalko.com/exalate/display/ED/JQL+Functions


      Eileen

      1. Moogambigai G R

        Hi Eileen Reimers 


        Need to show my destination ID in source project JQL result.


        But the above link, it will take only exalated records.


        Regards,

        Moogambigai G R

      CommentAdd your comment...