Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

script runner run unexpectedly multiple times for Issue update when we upload multiple files at once

imasaka_yasufumi July 12, 2023

We are currently developing script listners for integration between Jira tickets and ServiceNow tickets.

What we would like to do is that the attachement files are uploaded to Jira tickets, then automatically send them to ServiceNow tickets.

Basically, we can do it that the files uploaded to Jira are sent to ServiceNow via ServiceNow API.

But we faced the problem that if we upload the multiple files at once, then they are sent to ServiceNow multiple times because the script listner run as many times as the amount of uploaeded file at once.
(ex. if we upload 3 files at once, then script listner run 3 times.)

the script run if “Issue Updated“.

1 answer

0 votes
Nic Brough -Adaptavist-
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
July 12, 2023

Welcome to the Atlassian Community!

I think you have answered your own question - if you upload 3 files, the script runs 3 times.

My guess would be that your script has been coded to copy all attachments to your ServiceNow system, not just the one that was uploaded on this run.  When attachment events are close together, this will lead to many copies of the files being sent to ServiceNow, because the script is uploading everything attached, mostly after the attachments have been successfully attached.

I think your script probably needs to look at the "file attached" event more closely - extracting the single file that was attached and only sending that to ServiceNow, rather than "all attachments"

imasaka_yasufumi July 12, 2023

@Nic Brough -Adaptavist- 

Thank you for suggestion!

I tried to  modify script to run when "file attached" as you suggested, I couldn't get issue_id of JIRA ticket. The event "file attached"(actually it's "attachement created" event) includes only timestamp and the type of webhook event and can't specify ticket key as follwing.

"webhookEvent": "attachment_created", "timestamp": 1689218648027

Do you have any suggestion to get ticket key if we use "attachment created" event?

imasaka_yasufumi July 12, 2023

additional information; we use JIRA cloud.

Nic Brough -Adaptavist-
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
July 14, 2023

I think you need to be looking at the script's triggers and code.

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
PREMIUM
PERMISSIONS LEVEL
Product Admin
TAGS
AUG Leaders

Atlassian Community Events