2
1
0

Hello,
i am using this code from your site and it doesnt work.
it is creating the Sub-Task as a regular Task and not as a sub-task.

OutGoing Sync:

replica.parentId       = issue.parentId


Incominfg Sync:

if(firstSync){

   issue.projectKey   = "RTFACT"

   // Set type name from source issue, if not found set a default

   issue.typeName     = nodeHelper.getIssueType(replica.typeName)?.name ?: "Bug"

}


if(firstSync && replica.parentId){

    issue.typeName     = "Sub-task" //Make sure to use the right subtask type here.

    def localParent = nodeHelper.getLocalIssueFromRemoteId(replica.parentId.toLong())

    if(localParent){

        issue.parentId = localParent.id

    } else {

       throw new com.exalate.api.exception.IssueTrackerException("Subtask cannot be created: parent issue with remote id " + replica.parentId + " was not found. Please make sure the parent issue is synchronized before resolving this error" )

    }

}

    CommentAdd your comment...

    2 answers

    1.  
      4
      3
      2

      Hi!


      The problem is that Jira initially create the subtask without parent Id and Exalate tries to sync it like that. You can fix that by adding this on top of your outgoing script:


      if(issue.typeName == "Sub-task" && issue.parentId == null) return
      
      
      replica.parentId = issue.parentId


      That will make sure that Exalate will only sync when the parentId is set by Jira

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

        What is the problem you encounter?


        1. Ariel Einfeld

          when i create a sub-task, it syncs it to the other instance as a Story level issuetype, not as a sub-task under the parent.

        2. Francis Martens (Exalate)

          Can you investigate why it is becoming a story

          Looking at 

          issue.typeName = nodeHelper.getIssueType(replica.typeName)?.name ?: "Bug"

          is that the incoming sync is about a story, stories are not sub-tasks.

          Can you check it out?


        3. Ariel Einfeld

          That line is just a checker to check if it gets an issueType during the migration, if not it will set it as a Bug.

          but that is not the issue here as i have another function right after that where i reset the issue type.


          if(firstSync && replica.parentId){

              issue.typeName     = "Sub-task" //Make sure to use the right subtask type here.

              def localParent = nodeHelper.getLocalIssueFromRemoteId(replica.parentId.toLong())

              if(localParent){

                  issue.parentId = localParent.id

              } else {

                 throw new com.exalate.api.exception.IssueTrackerException("Subtask cannot be created: parent issue with remote id " + replica.parentId + " was not found. Please make sure the parent issue is synchronized before resolving this error" )

              }

          }

        4. Ariel Einfeld

          and its not working, its creating a story.

        5. Francis Martens (Exalate)

          If the incoming sync is a story, parentId is not set and the section


          ...issue.typeName = "Sub-task" //Make sure to use the right subtask type here.
          ....

          Is totally ignored.

          Can you check the issue type of the incoming sync by throwing an exception

          throw new Exception("Incoming issue type = ${replica.typeName}")

          Put this on line 1 of your incoming sync on the target side.
          Whenever a new message comes in, it will raise an error with the detail you are looking for.
          Part of the details is the 'remote replica'.  Have a look into that also - and check if the parentid is set (or not)

        CommentAdd your comment...