How to sync only attachments (images) that are mentioned in description?

Originally asked by Samip K Banker on 02 October 2019 (original question)


We only want to sync images (mentioned in the description) when the sync happens from original to remote how can we achieve that?


Answer by Francis Martens (Exalate) on 02 October 2019

Hi Samip K Banker

Assume the source is blue and the target red

From Source to Target - filter the images

In the outgoing sync of the blue, replace the

replica.attachments = issue.attachments

with the following statement

replica.attachments = issue.attachments.findAll { attachment ->
                      attachment.mimetype.startsWith("image/") &&
                      issue.description.contains(attachment.filename)
                  }


This will collect all the attachments of type image which are referenced in the issue description into the message sent from source to target

In the incoming sync of the red, ensure the following statement is executed

issue.attachments = attachmentHelper.mergeAttachments(issue, replica)

From Target to Source - Disable attachment sync by

In the outgoing sync of the red, remove

replica.attachments = issue.attachments

In the incoming sync of the blue - remove the

issue.attachments  = attachmentHelper.mergeAttachments(issue, replica)

Let me know


Comments:

Samip K Banker commented on 03 October 2019

user-50445 :

I am looking to do somehting similar to this but just for Description…

https://docs.idalko.com/exalate/display/ED/How+to+filter+attachments+in+local+comments

~Samip

Francis Martens (Exalate) commented on 03 October 2019

can you elaborate?

do you want the images referenced in the comments or in the description?

Samip K Banker commented on 03 October 2019

From Description (as the summary of the entry suggest). I looked at the documentation and I can only find how to do what I want to do for Comments… I want to see if you have any example to do it for Description.

Francis Martens (Exalate) commented on 03 October 2019

Did you try the suggestion I made in this answer?

It is exactly that.

Samip K Banker commented on 03 October 2019

Sorry… I didn’t read your feedback proprely yesterday. Thanks. I will try it out.