# How can I use a custom Script rule to sync in-line Images in Comments (Zendesk to Jira)

**URL:** <https://community.exalate.com/t/how-can-i-use-a-custom-script-rule-to-sync-in-line-images-in-comments-zendesk-to-jira/4857>\
**Category:** General Questions\
**Tags:** exalate, jira-cloud, zendesk-jira, migrated\_question, inprogress\
**Created:** [November 4, 2024, 7:27am UTC](https://community.exalate.com/t/how-can-i-use-a-custom-script-rule-to-sync-in-line-images-in-comments-zendesk-to-jira/4857 "2024-11-04T07:27:57Z")\
**Posts on this page:** 2\
**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, 7:27am UTC](https://community.exalate.com/t/how-can-i-use-a-custom-script-rule-to-sync-in-line-images-in-comments-zendesk-to-jira/4857/1 "2024-11-04T07:27:57Z")

</div>

_Originally asked by Michael on 16 September 2021 [(original question)](https://oldcommunity.exalate.com/questions/37552382)_

* * *

Per the title, my use case is for syncing data between Zendesk and Jira.

I have gotten description formatting to sync using:

```auto
replica.description = nodeHelper.getHtmlDescription(Zendesk3.issue)
Jira.issue.description = nodeHelper.toMarkDownFromHtml(replica.description)

```

and comment formatting to sync using a custom script rule.

```auto
def includeComments = commentHelper.mergeComments(Jira.issue, replica).collect{it}
Jira.issue.comments += nodeHelper.toMarkDownComments(includeComments)

```

However, any in-line image in a note in Zendesk results in a Jira comment that looks like:

 ![](https://europe1.discourse-cdn.com/flex018/uploads/exalate1/original/1X/1cbe635ce355e4af79afc1a6bb21e5eae4213bfa.png)

Exalate support had asked me (In a zoom call) to post a question over here to document how to use the html to wiki feature in the script.

* * *

---

<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, 7:27am UTC](https://community.exalate.com/t/how-can-i-use-a-custom-script-rule-to-sync-in-line-images-in-comments-zendesk-to-jira/4857/2 "2024-11-04T07:27:59Z")

</div>

_Answer by Ariel Aguilar on 05 November 2021_

**Solution**

If you look at the content being sent in the comment containing attachments - it contains something like

​ !([https://d3v-francis.zendesk.com/attachments/token/AzEkdy3kmZ8X9MsqzAlG8Aarg/?name=hpalm-jira.png](https://d3v-francis.zendesk.com/attachments/token/AzEkdy3kmZ8X9MsqzAlG8Aarg/?name=hpalm-jira.png))​

By converting it into something like

!

Jira will be able to show the inline attachment.

Note that works only if the attachments is accessible under that token. The day that the token is invalidated, the attachment will not be reachable, so this is not really a solution.

Implementation

It is easy to replace the !(\<filename\>) into !\<filenname\>! by using following construct

 ![](https://europe1.discourse-cdn.com/flex018/uploads/exalate1/original/1X/9df00e6f026757af6ed9d0651bfd135fd3635fa8.png)

Line 1 uses the mergeComments to iterate over all the comments in the replica and summons the closure to be run.  
Line 4 calls the replaceAll groovy string method. For each string segment matching the regexp a replacement is created. The replacement contains the necessary code to show the image with a maximum width of 512.

Code is available [here](https://stash.idalko.com/snippets/e18398a36dc745a486a09fa3ce059f12)

* * *
