Script for desciption from last comment

Originally asked by ben friedman on 26 November 2021 (original question)


Hi,

i have a zd<>Jira connection.

i need the jira’s description to take on the last comment from ZD, at the time of first sync only.

can you advise a script?


Answer by Francis Martens (Exalate) on 26 November 2021

It is easy to get the last comment from the comment array using following snippet in the outgoing sync on the zendesk side

def lastComment = issue.comments?.getAt(-1)
replica.description =  lastComment
// use next to check the result of the statement - this generates an error.debug.error("Replica description = ${replica.description}")

Comments:

Francis Martens (Exalate) commented on 26 November 2021

You might also be interested in only send the comment set from the moment of the exalate

It is an advanced configuration with a message dance to store a local value.

ben friedman commented on 26 November 2021

thanks Francis,

i’ve added that and now getting an error on the Jira side -

Internal comments cannot be processed. The reason is: Request Type custom field is required, but not set…

ive tried to set the following, but to no success -

on[“”“avo”“”].issue.customFields.“Customer Request Type”.value = “Customer Support request”

Francis Martens (Exalate) commented on 27 November 2021

This is a separate topic.
Check Setting the request type using the visual editor

ben friedman commented on 01 December 2021

Hi Francis, i’ve followed the guide, and now have the below, but it still produces an error:

if (firstSync) {
on[“”“avo”“”].issue.customFields.“Request Type”.value = “Customer Support request”
}

def lastComment = issue.comments?.getAt(-1)
on[“”“avo”“”].description = lastComment
// use next to check the result of the statement - this generates an error.
debug.error(“Replica description = ${replica.description}”)

Francis Martens (Exalate) commented on 01 December 2021

What is the error?

ben friedman commented on 03 December 2021

logs are available here

https://drive.google.com/file/d/116sEiB7HSzNv8En0KmM00pMk-IdmEZwK/view?usp=sharing

Ariel Aguilar commented on 17 January 2022

Hi there,

Let me help here, I checked on the logs and found the error:

“Caused by: com.exalate.api.exception.script.IssueTrackerScriptException: Replica description = סתם מידע”

So, you need to do the following to make it work:

if (firstSync) {
    on["""avo"""].issue.customFields."Request Type".value = "Customer Support request"
}
def lastComment = issue.comments?.getAt(-1)
on["""avo"""].issue.description =  lastComment

The word “issue” on the last line was missed before. Try out and let me know.

Kind regards,

Ariel