How to fill a default value for custom field in Zendesk...?

Originally asked by Kazim Yildirim on 23 May 2023 (original question)


Hi,
when I am starting the sync from JIRA cloud to Zendesk, I am transferring the resolution field from JIRA to ZD.
But in the case, when this field is not set in JIRA the value is null…how can I set their a default value, so that I am not getting an error?

Thanks for Help.
Kazi

def resoMap = [
“Fixed”: “fixed”,
“No Bug”: “no_bug”,
“Blocked”: “won_t_fix”,
“Duplicate”: “duplicate”,
“Incomplete”: “incomplete”,
“Cannot Reproduce”: “cannot_reproduce”,
“Done”: “done”,
“Won’t Do”: “won_t_do”,
“Declined”: “declined”,
]
issue.customFields.“[JIRA] Resolution”.value=resoMap[replica.resolution.name]


Answer by Syed Majid Hassan on 24 May 2023

Thank you for joining the call earlier today. We were able to resolve this with the following snippet:

if (replica.resolution?.name)

   Assign the resolution to the ZD field

else

  Assign default to ZD field

Thanks

Majid


Comments:

Syed Majid Hassan commented on 05 June 2023

Hi Kazim Yildirim ,

I believe we completed this on call.
Please mark the answer accepted if all is well.

Thanks

Majid