I have setup a simple listener to create an issue when a field is selected in JIRA during an update event. The problem is, when a further change is made to the same ticket (which generates another update event) the listener picks this up and creates another issue (providing the condition is still true)
How can I amend the listener to create an issue only when the specific action is done, and nothing else.
Condition:
'SpecificValue' in cfValues['SpecificCF']*.value
Thanks all.
Steps to recreate:
I think what you need is to remove the condition and move it into the script code itself, because the condition will always be true, no matter what, with each issue update.
Taking https://community.atlassian.com/t5/Adaptavist-questions/Listener-Condition-for-CustomField-change-AND-custom-date-field/qaq-p/1009955 as inspiration, the steps would be:
- issue get updated, thus this fires IssueUpdated event
- the issue itself is "already updated" when the 'issue' variable enters the script code, hence you need to find if it was the CustomField value itself that was changed - by looking into what was changed which is part of the event
- inside the code, see if CustomField was changed as part of this update, if so, then you do what you need to do, otherwise, we can safely assume the field was not changed, thus we don't care
So to do that, you use the event to find what was changed
def change = event?.getChangeLog()?.getRelated("ChildChangeItem").find {it.field == "SpecificCF name"}
If there was a change, you can now find what the new value is:
def newString = change?.get("newstring")
And if it was just set on the issue
if (newString != null && newString.equals("SpecificValue")
Then it should be safe to assume you're good to do the other steps.
I don't have IDE in front of me right now so I hope the code snippets are correct, if not I can take a look tomorrow and fix them.
This also depends how your listener is implemented currently and if you are able to fit these in.
In any case - need to use the event to find if the custom field was actually changed, as condition will always be true in this context.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
A simple hack would be to populate a custom field (maybe named as flag) to some value in the original issue after the new issue is created. Don't need to add this field to the issue screens but use it to evaluate if the listener needs to process new issue creation. If the custom field is empty proceed with issue creation else exit.
Let me know if you need more information.
Please mark it as answered if it solves your problem.
Thanks,
Aditya
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.