Questions for Confluence license has expired.

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

mapping internal/public attachments from SD to ZD

 
1
0
-1

Hi,

i need a script that maps attachments made as internal/external in SD, to be internal/external, respectively, in ZD. 

Please assist.


Thanks


    CommentAdd your comment...

    1 answer

    1.  
      2
      1
      0

      Hi Ben,

      Could you please give a try to the following:

      if (executionInstanceName == "zd us") {
          replica.getClass().fields
          def locked = replica.getClass().declaredFields.find{it.name == "_locked"}
          locked.setAccessible(true)
          locked.set(replica, false)
          if(replica.addedComments.reverse().find()?.internal == true && !replica.addedAttachments.empty){
              replica.addedAttachments = replica.addedAttachments.collect{
                  attachment ->
                  def lockeda = attachment.getClass().declaredFields.find{it.name == "_locked"}
                  lockeda.setAccessible(true)
                  lockeda.set(attachment, false)
                  attachment.internal = true;
                  attachment
              }
          }
          issue.attachments = attachmentHelper.mergeAttachments(issue, replica)
      }

      Thanks,

      Ariel

      1. ben

        Thanks, Ariel, that does the work but its still not a complete setup (sad)

        so that files arent duplicated in the sync to ZD, the attachment mapping in the visual connection was turned off. 

        so no, files from ZD are not arriving on SD (the script takes from SD to ZD, but not from ZD to SD).

        can you please advise a script to take attachments from ZD to SD (preferably such that its still respective of internal/external?


      2. Ariel Aguilar

        Hi Ben,

        Yes with the visual mapping off, you may add the following to it to make look like this:


        if (executionInstanceName == "zd us") {
            replica.getClass().fields
            def locked = replica.getClass().declaredFields.find{it.name == "_locked"}
            locked.setAccessible(true)
            locked.set(replica, false)
            if(replica.addedComments.reverse().find()?.internal == true && !replica.addedAttachments.empty){
                replica.addedAttachments = replica.addedAttachments.collect{
                    attachment ->
                    def lockeda = attachment.getClass().declaredFields.find{it.name == "_locked"}
                    lockeda.setAccessible(true)
                    lockeda.set(attachment, false)
                    attachment.internal = true;
                    attachment
                }
            }
            issue.attachments = attachmentHelper.mergeAttachments(issue, replica)
        }
        if (executionInstanceName == "jira") {
        issue.attachments = attachmentHelper.mergeAttachments(issue, replica)
        }

        With this configuration you may be able to even delete the mapping and both ways should work now. You may try this first and come back if the attachments are not going as expected from ZD to SD.

        Kind regards,

        Ariel

      3. ben

        hi ariel, the attachments arent going as they should. getting an error. please advise which information i should provide so you can look into it. thanks

      4. ben

        Hi Ariel, had a typo in the copy/paste of the script. its working as expected. 

        many thanks!!!

      5. Ariel Aguilar

        Great! I was going to get back to you.

        Best regards,

        Ariel

      CommentAdd your comment...