Hello,
I have Jira 6.3.5 with Script Runner 3.0.6
Script Listeners - Send a custom email
Events: Issue Closed
Conditions -
issue.subTasks.size() > 2
issue.labels.any{it.label=='NewHire'}
issue.parentObject?.subTaskObjects?.every{it.resolution}
The problem is that the labels condition is not working (issue.labels.any{it.label=='NewHire'}).
It is sending and email regardless of the labels, the email need to be sent only if it matches that of a NewHire label.
Any idea why it is ignoring the labels condition?
Thanks in advance.
You're misunderstanding how conditions work. The entire script is evaluated, and the result of the last line determines whether the condition passes or not.
You can either just return the last line, which is suitable for one-liners, or explicitly use variables and / or a return statement.
So you want something like:
(! issue.isSubTask() && issue.subTasks.size() > 2) && issue.labels.any{it.label=='NewHire'} && (issue.isSubTask() && issue.parentObject.subTaskObjects.every { it.resolution })
Your conditions as you wrote them don't really make sense, because you're checking that there are more than 2 subtasks, and also that all the subtasks siblings are resolved.
I used - issue.labels.any{it.label=='NewHire'} && (issue.isSubTask() && issue.parentObject.subTaskObjects.every { it.resolution }) and removed the sub-tasks greater than 2. It is working great! I tried the && before, however the part I was missing was another && for the subtask. Thanks again!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You may try something like...
"NewHire" in issue.labels*.label if (issue.isSubTask()){ issue.parentObject.subTaskObjects.every {it.resolutionObject} } else false
without using "issue.subTasks.size() > 2"
Because you can't say this issue must have more than 2 sub tasks and its parent must have all its sub tasks closed. Simply because you can't have a subtask of a subtask.
The last part means that if you are not closing a subtask the mail would not not be sent.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
In this case I also expect to have the label "NewHire" in the sub task and not on the parent one.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Yes NewHire is the label in the Sub-task. I tried the above code, the issue is when there is any label in the Sub-task, it still sends out an email. It's ignoring the NewHire label. I've tested just with a label ABC and it still sends out an email.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I can't reproduce the issue related to labels. May I have a screenshot of the settings you used on the listener configuration screen?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Dianne, what you would like to achieve with:
issue.parentObject?.subTaskObjects?.every{it.resolution}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
The email needs to be sent only when all of the sub-tasks are closed. I have created new sub-task issue types, so the parent ticket has ootb sub-tasks plus custom sub-task issue types
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You should not be able to have a subtasks hierarchy, I mean you should not be able to create a sub task from another subtask. I see it as, I have this issue that must have at least 2 subtasks and a label "NewHire". The current issue is not a subtask itself so you can't retrieve the parent. That parentObject will always be so every time your condition will be false.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I've tried to reproduce your problem but the only issue I have is related to the third line and not the second one. I would suggest using this syntax (it has the same behaviour as your code but it's simplier): "NewHire" in issue.labels*.label
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.