Hi,
I have implemented my first listener within an existing project (approx. 400 issues). I want to fire the listener (which calculates couple of custom fields) without the need to open each issue. What is the event to use? I implemented "issue created" and "issue updated" event but this only fires listener for created or updated issues and not all issues in my project, of course. Can anyone help a bloody beginner?
Hi @Michael Preiss welcome at the community.
The idea of listeners is to listen to events raised by SOME object (issue, project, authentication module....), so it will never cover ALL the objects. It also would not be smart because in case of a large number of objects it definitely could have peerformance impact.
So you have to use listener just to be notified that "something happened" and do the rest on your own. If you will describe your use case in detail, we can design the solution together (if it is not some rocky science :))
Hi Martin, many thanks for replying.
Some more information:
I have a running project with approx. 400 items. Now I need to define a new custom field (a KPI) that needs to be calculated based on input of existing custom field. I have wrote the code for the listener. Now I need kind of a bulk update - so that all custom fields (again approx. 400) are calculated. Otherwise and due to the event trigger "issue updated", i would have to open each single issue manually. So I somehow need to fire the listener for all issues within the project. Can you help?
Michael
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi, in future the trigger "issues updated" is perfectly fine but I need to do an initial bulk update so that all issues have this calculated field value.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
ok I can see the multiple ways
Let me know if you need additional help :)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
what do you mean with "Invoke Edit operation in bulk"? Is this a JIRA function?
Michael
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi, yes, you can
You can check documentation
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.
Hi Martin, could you also help me with another issue?
I have two custom fields (both calendar picker) and in one of my listeners I need to identify the months in between those two dates and use it to continue in the listener and to give it back into another custom field. As I am not used to programming, this seems to be a quite complex challenge for me...
With copy&paste from existing listeners, I achieved the following:
def cfEffectiveDate = cfm.getCustomFieldObject("customfield_10048") //First Date
def effectiveDate = cfEffectiveDate.getValue(issue) as Timestamp
def cfEffectiveDateFive = cfm.getCustomFieldObject("customfield_10049") //Second Date
def effectiveDateFive = cfEffectiveDate.getValue(issue) as Timestamp
def effectiveDateYear = effectiveDate.getYear() as Integer
effectiveDateYear -= 120 //NO IDEA WHY THIS IS NEEDED
def effectiveDateMonth = effectiveDate.getMonth() as Integer
def effectiveDateYearFive = effectiveDateFive.getYear() as Integer
effectiveDateYearFive -= 120 //NO IDEA WHY THIS IS NEEDED
def effectiveDateMonthFive = effectiveDateFive.getMonth() as Integer
Now this is where I stand...now I need to define the Duration in months in between and give it back to the custom field "Duration (months)" like this
issue.setCustomFieldValue(ComponentAccessor.getCustomFieldManager().getCustomFieldObject("customfield_11776"), duration ? duration : null) // Set cf duration
What I am missing is something in between to calculate duration
def duration = XXXXX as Double
Probably there is also a Integer and Double issue in this whole thing which I am not able to solve...
Can you help?
Michael
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.