Forums

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

update an issue field on event "issue updated"

RPO November 15, 2024 edited

Hello,

I want to update a Field of an issue every time this issue is updated. To do that i am using a listener on the event "issue updated" with a little script:

def summary = event.issue.getSummary()
def type = event.issue.issueType.getName()
if (type == 'Epic') {
    event.issue.update {
      setEpicName(summary)
  }
}

However i imagine this it would create an infinite trigger of the "issue updated" event, as i am updating the issue with my script either.

Is this the case? or scriptrunner's scripts do not trigger events events like "issue updated"?

 

setEpicName

4 answers

1 accepted

0 votes
Answer accepted
RPO November 22, 2024

I run some tests and the answer is yes.

The command

event.issue.update {... }

will  generate a new "issue updated" trigger.
if not used correctly the issue will be updated recursively many times.

I have solved the problem with this code:

import com.atlassian.jira.event.type.EventDispatchOption
import com.atlassian.jira.issue.Issue

Issue issue = event.getIssue()
def type = issue.issueType.getName()
def summary = issue.getSummary()
def epicName = issue.getEpicName()
if (type == 'Epic') {
if (summary != epicName) {
issue.update {
setEpicName(summary)
setEventDispatchOption(EventDispatchOption.DO_NOT_DISPATCH)
setSendEmail(false)
}
}
}
0 votes
Leonel Goitia November 15, 2024

Hi, agree with @Marc - Devoteam

you can use this trigger

image.png

RPO November 15, 2024

I am exploring possibilities.  :)

0 votes
Uladzislau Samuseu
Contributor
November 15, 2024

Hi @RPO 

May be you have to add a check at the beginning like "if summary is not updated".

RPO November 15, 2024

true, i will.

but the main question is if the script triggers automatically an event when i update an issue, or not

0 votes
Marc - Devoteam
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.
November 15, 2024

Hi @RPO 

Welcome to the community.

Why don't you use an automation rule for this?

RPO November 15, 2024

I am exploring possibilities.  What is the benefit of automation other than simplicity of implementation?

anyway, the main question is if the script triggers automatically an event when i update an issue, or not

Suggest an answer

Log in or Sign up to answer
TAGS
atlassian, atlassian government cloud, fedramp, webinar, register for webinar, atlassian cloud webinar, fedramp moderate offering, work faster with cloud

Unlocking the future with Atlassian Government Cloud ☁️

Atlassian Government Cloud has achieved FedRAMP Authorization at the Moderate level! Join our webinar to learn how you can accelerate mission success and move work forward faster in cloud, all while ensuring your critical data is secure.

Register Now
AUG Leaders

Atlassian Community Events