Hello,
in my project I use 2 different issue types. The issues of both types can have the same assignee. Hence my goal is to link the all issues from the issuetype A to an issue of the issuetype B, if the assignee is the same (and some other conditions - but it doesnt matter for this question). In the ideal case I would have a list for my issues from the issuetype B, where all the respecive issues from the issuetype A are named.
Later on I would also like to get a customfield value displayed from the linked issues as well. So e.g. the customfield is costs. And all issues from the issuetype A are materials, I would like to display all names of the materials and the respective cost values on the issues from the issuetype B. So in a next step I could go ahead and count al the costs together and safe this result in a new customfield for the issues of the issuetype B.
Is this possible and how would I best start? I tried with Fields --> Issue(s)Picker but I couldnt even configure a jql that searches for issues with
assignee = {{assignee.displayName}}
looking forward for your suggestions :D
I think https://library.adaptavist.com/entity/add-or-update-the-issue-link-for-an-issue-in-jira probably gives you example code for working with issue links
Then this one can show you how to go over and look at all linked issues - https://library.adaptavist.com/entity/calculate-the-sum-of-all-values-of-a-custom-field-in-linked-issues (obviously, dump the "sum" bit in favour of your code to do what you need with the custom field you find, although it might help with "summing the cost" later)
Hey @Nic Brough -Adaptavist- first of all thank you for your reply.
I tried to create a listener that links the issues but it doesnt work. I dont even have an error but when I create a issue (and this creation triggers the listener), the issue has no links.
here is my code:
Can you see why it doesnt work? What can I do?
I am very glad that you are helping me!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
If there are no errors going into the logs (your assert statements should be logging something if there were errors happening within the linking block, if not a crash), then I suspect your code is never getting into the linkage block - my guess would be that the search is not finding any issues to link!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
@Nic Brough -Adaptavist- Yes there are no logs. I think you are right, that the code never gets in the linkage block but the query should be alright. I tested it in jira and I found all three issues (see below).
What would you do to find the problem?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Also, the only part of the code that I dont understand is the "sequence"... what does it do and might this cause the error? @Nic Brough -Adaptavist-
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I actually found the error, apparently it doesnt work if I write
Issue triggerIssue = event.getIssue()
if (triggerIssue.getIssueTypeId() != 10203) {
return}
... when I go just
Issue triggerIssue = event.getIssue()
... then it works, but I dont know why and how I can now make clear that the linking should only apply to specific issues
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Excellent, that's more than I was going to get! I was going to talk about logging and following every step in the sequence, but you've got further than that I think.
In your first snippet of code, the "return" will stop the script, ending it with a return code. So if your first found issue is not of the right type, it won't read any of the others.
What you probably want is something more like
if (triggerIssue.getIssueTypeId() = 10203)
{
<do all the linking stuff for this issue
}
This should keep looping over the found issues until you've processed all of them
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Best Thanks to you @Nic Brough -Adaptavist- .
It finally worked when I made some little changes to your code.
Issue triggerIssue = event.getIssue()
String ISSUE_TYPE_ID = "10203" /
if (triggerIssue.getIssueTypeId() == ISSUE_TYPE_ID){
<Linkage Block>
}
I only have one last struggle with that code :)
Regarding the JQL: I need the assignee and the value of an customfield as condition for my destinationIssues
"project = SUD and issuetype = 'SUD Modul' and assignee = 'Prof. Volker Bruhns' and CF ~ 'Value of Customfield'"
When I write is as a string I have no problems and the search delivers the proper issues.
But when I write is generic and use variables like:
"project = SUD and issuetype = 'SUD Modul' and assignee = ${triggerIssue.getAssignee().displayName} and CF = ${triggerIssue.getCustomFieldValue(customFieldManager.getCustomFieldObject(10308))"
Then the code doesnt work. I used log.info to print out what e.g. triggerIssue.getAssignee().displayName would look like and it is definetely the same as 'Prof. Volker Bruhns'.... which worked.
I hope you can follow me :)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I think I found a workaround :) Not very beautiful but it works I guess
String triggerIssueSemestercode = triggerIssue.getCustomFieldValue(customFieldManager.getCustomFieldObject(10308))
String triggerIssueAssignee = triggerIssue.getAssignee().displayName
String foundIssueSemestercode = foundIssue.getCustomFieldValue(customFieldManager.getCustomFieldObject(10308))
String foundIssueAssignee = foundIssue.getAssignee().displayName
if (triggerIssueSemestercode == foundIssueSemestercode && triggerIssueAssignee == foundIssueAssignee){
I used a second If conditon here, so the code only goes into the linkage block, when the if statement ist true
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.