What is the different between script runner event:Issue Updated/CustomFieldUpdatedEvent ? Edited

Hi Support,

What is the different between script runner's event:

Issue Updated/CustomFieldUpdatedEvent ?

Because I write a custom listener script to judge the customfield's value,when the condition is true then auto clone the issue to other projects.

I set the event: Issue Updated/CustomFieldUpdatedEvent.

I find a bug that when the custom field condition is true, it auto clone the issue(it is correct),but users upload the attachment three times,it also auto clone issue to other projects(it is wrong).

Is it jira's bug?We use JIRA 7.2.6 version.

Should I  just need to remove Issue Updated to  avoid this problem.

Thanks for your great support in advance.

1 answer

Issue Updated: Triggered if some field of the issue is changed.

CustomFieldUpdatedEvent: Triggered if the name or description of the field is changed. 

Should I  just need to remove Issue Updated to  avoid this problem?

It depends on your requirements. 

We only want to auto clone issue when the custom field condition meet the requirement.

What should I need to put ?

Please note that these are not "script runner events".  The events are fired by activity in Jira, and you're using Script Runner to react to them.

From "We only want to auto clone issue when the custom field condition", I think you need to forget CustomFieldUpdatedEvent.

It sounds like your requirement is "Clone issue if a custom field changes to <a value>".  You will need the IssueUpdated event for that, and to then check the value of the custom field as the condition.

If my guesses there are wrong, could you clarify the requirement a bit more?

The questions is that I have already set the custom field to meet some condition and then to auto clone the issues,but when users update the attachment it also meet the condition then auto clone the issue,but this issues should not auto clone.

What should I need to avoid this problem?

Sounds like the condition is incorrect.  Are you checking just for a change of that custom field?  Could you show us the config?

The condition is correct,but if you just use IssueUpdated event then the condition is always true then someone update the issue ex:upload an attachment it also auto clone issue,but it is wrong.

Do you have any suggestions about it ?

Hey Cloud!

So are you wanting the issue to only be cloned when a certain field is updated in an issue? If so, but the clone is being made when some other field is being updated, then I'd agree with Nic in that your condition is probably wrong. If, however, the attachment field is actually the field that is supposed to trigger the event, then I imagine your issue is that you need to check for if a clone of the issue already exists; and not to make another one if it does.

Could we please take a peek at your listener config and condition to get a better idea of what might be happening in your code?

Thanks! 

Aidan

1.So are you wanting the issue to only be cloned when a certain field is updated in an issue?

YES

2. If so, but the clone is being made when some other field is being updated, then I'd agree with Nic in that your condition is probably wrong. 

No,Because I put IssueUpdated event and the field have already changed to my trigger condition and then happen issue updated then it is auto clone?Is it correct action?

Could we please take a peek at your listener config and condition to get a better idea of what might be happening in your code?

Could you please give me the mail address ?

Hi Support, please help to solve this problem as soon as possible.

Hi Cloud, 

Please post it below and we will follow up with you.

Katy

Adaptavist Product Support 

Hi Support,

Because issue updated event include all event like update issue and upload file.

We need to judge only when customfield update then auto clone the issue ,thank you!

This is correct.  An issue updated event tells us the issue has changed, and how. 

Your condition needs to look specifically at one field within that.  SR can do that easily, but it sounds like you have not configured it correctly.

Please, tell us what you have configured for this.  We can't really help you until you tell us that.

Hey Cloud!

If you need to judge which custom field is the one that has been updated, you can use something like the ChangeHistoryManager to see exactly which field was the updated field.

For example:

def chm = ComponentAccessor.changeHistoryManager
def changeHistory = chm.getAllChangeItems(event.issue)

// check that the field changed was the specified custom field
if(changeHistory.field.last() == "Custom Field Name")
{
//Execute the rest of your listener code
}

That should allow you to control which field the listener fires on. But if you have an issue with a condition somewhere else in your listener, this won't be a solution. But try to implement that and test it out. Then let us know how it goes! :D

Best of Luck!

Aidan

Hi Support,

Good Job,That is what I need.

So I only need to put Issue updated event and remove customfield updated event to test these code?

Thank you. 

Yes, as discussed before, the "custom field updated" event is for changes to the configuration of the custom field itself, not the values held in it for issues.

Suggest an answer

Log in or Sign up to answer
How to earn badges on the Atlassian Community

How to earn badges on the Atlassian Community

Badges are a great way to show off community activity, whether you’re a newbie or a Champion.

Learn more
Community showcase
Published May 30, 2018 in Marketplace Apps

Three tips for boosting your board's efficiency with Story Maps

Trello is one of the most effective tools for driving your sprints. It's customizable for every Agile team and product owners and Scrum masters (SM) love it. However, Agile teams often struggle with:...

823 views 2 9
Read article

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you