# How to only sync public attachments from Jira Service Desk

**URL:** <https://community.exalate.com/t/how-to-only-sync-public-attachments-from-jira-service-desk/4229>\
**Category:** General Questions\
**Tags:** cloud-jira, migrated\_question\
**Created:** [November 4, 2024, 6:40am UTC](https://community.exalate.com/t/how-to-only-sync-public-attachments-from-jira-service-desk/4229 "2024-11-04T06:40:16Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![xl8bot](https://dub1.discourse-cdn.com/flex018/user_avatar/community.exalate.com/xl8bot/32/324_2.png) [@xl8bot](https://community.exalate.com/u/xl8bot)\
**Post date:** [November 4, 2024, 6:40am UTC](https://community.exalate.com/t/how-to-only-sync-public-attachments-from-jira-service-desk/4229/1 "2024-11-04T06:40:16Z")

</div>

_Originally asked by Juan Grases on 19 May 2020 [(original question)](https://oldcommunity.exalate.com/questions/11339557)_

* * *

I want to only sync attachments that are references from public comments

* * *

---

<div class="post-metadata">

**Author:** ![xl8bot](https://dub1.discourse-cdn.com/flex018/user_avatar/community.exalate.com/xl8bot/32/324_2.png) [@xl8bot](https://community.exalate.com/u/xl8bot)\
**Post date:** [November 4, 2024, 6:40am UTC](https://community.exalate.com/t/how-to-only-sync-public-attachments-from-jira-service-desk/4229/2 "2024-11-04T06:40:17Z")

</div>

_Answer by Juan Grases on 02 June 2020_

This block should make it:

```auto
def publicComments = issue.comments.findAll{!it.internal}

def isMentionedInPublicComments(attachment, publicComments) {
	publicComments.any {c -> 
        c.body.contains("[^" + attachment.filename + "]") ||
        (c.body =~ (/!${java.util.regex.Pattern.quote(attachment.filename)}(\|.*!|!)/.toString())).find()
    }
}

replica.attachments = issue.attachments.filter{isMentionedInPublicComments(it, publicComments)}
  
    

```

* * *

---

<div class="post-metadata">

**Author:** ![Normann\_P\_Nielsen](https://dub1.discourse-cdn.com/flex018/user_avatar/community.exalate.com/normann_p_nielsen/32/595_2.png) [@Normann\_P\_Nielsen](https://community.exalate.com/u/Normann_P_Nielsen)\
**Post date:** [October 3, 2025, 7:54am UTC](https://community.exalate.com/t/how-to-only-sync-public-attachments-from-jira-service-desk/4229/3 "2025-10-03T07:54:25Z")

</div>

def publicComments = issue.comments.findAll{!it.internal}

def isMentionedInPublicComments(attachment, publicComments) {

```
publicComments.any {c -> 

    c.body.contains("\[^" + attachment.filename + "\]") ||

    (c.body =\~ (/!${java.util.regex.Pattern.quote(attachment.filename)}(\\|.\*!|!)/.toString())).find()

}

```

}

if (publicComments)

{

```
replica.attachments = issue.attachments.filter{isMentionedInPublicComments(it, publicComments)}

```

}

This is giving me:

No signature of method: java.util.ArrayList.filter() is applicable for argume…

for the line:

replica.attachments = issue.attachments.filter{isMentionedInPublicComments(it, publicComments)}

---

<div class="post-metadata">

**Author:** ![Normann\_P\_Nielsen](https://dub1.discourse-cdn.com/flex018/user_avatar/community.exalate.com/normann_p_nielsen/32/595_2.png) [@Normann\_P\_Nielsen](https://community.exalate.com/u/Normann_P_Nielsen)\
**Post date:** [October 3, 2025, 8:00am UTC](https://community.exalate.com/t/how-to-only-sync-public-attachments-from-jira-service-desk/4229/4 "2025-10-03T08:00:34Z")

</div>

.filter is not a method on a java.util.ArrayList

---

<div class="post-metadata">

**Author:** ![Normann\_P\_Nielsen](https://dub1.discourse-cdn.com/flex018/user_avatar/community.exalate.com/normann_p_nielsen/32/595_2.png) [@Normann\_P\_Nielsen](https://community.exalate.com/u/Normann_P_Nielsen)\
**Post date:** [October 3, 2025, 8:09am UTC](https://community.exalate.com/t/how-to-only-sync-public-attachments-from-jira-service-desk/4229/5 "2025-10-03T08:09:03Z")

</div>

This is working:

```auto
def publicComments = issue.comments.findAll{!it.internal}
 
def isMentionedInPublicComments(attachment, publicComments) {
	publicComments.any {c -> 
        c.body.contains("[^" + attachment.filename + "]") ||
        (c.body =~ (/!${java.util.regex.Pattern.quote(attachment.filename)}(\|.*!|!)/.toString())).find()
    }
}
 
if (publicComments)
{
    replica.attachments = issue.attachments.findAll{isMentionedInPublicComments(it, publicComments)}
}

```
