I am in the process of figuering out how to create a sub-task for an issue when a specific condition is met.
My use-case is:
When a user updates the custom field "Requires Attention" with the value of "Yes" I would like to create a sub-task under this issue which has the name of the Issue plus the letters "RA". I want this sub-task to be created only when that custom field is triggered and the issue is updated, I do not wish this sub-task to be created when the issue in general is updated. If the user de-selects the "Requires Attention" field and then selects it again it should create a new sub-task with the relevant information.
I was thinking about utilizing a Behaviour that checks for a specific change in value in one of the fields. When such a field changes I would like to create a sub-task under that issue. I also would like that sub-task to have certain information copied from its parent Issue. I am unsure what the code to achieve this would look like.
It is worthwhile noting that I utilized the Listener Create Sub-Task Script offered by ScriptRunner and it initially worked, but upon further utiliziation it did not quite meet the criterias I require.
For example, I want this script to run whenever a user modifies only one value ( a custom field) in the Issue Update form. The Listener can only listen to when an issue is updated in general. So it would run everytime a user updated an issue, therefore creating many sub-tasks which arent needed even though I wrote a conditional that would check if a certain custom field had a certain value. This failed because if the issue had its custom field value set already and the user updated an issue (perhaps updated the description), the script would run (because the custom field value was set to value defined in the condition) and create a new sub-task, which is something not desired.
Furthermore, I noticed the Listener had the Subtask Action option, but that did not help because if for somereason the sub-task was in the "Done" stage and then a user updated the issue it would re-open the sub-task even though there is no need for it to be re-opened. Perhaps, there is a way to utilize this Built-in Script, if there is please advise me as to how I can levarage it for the functionality I require.
Is there anyway this functionality can be implemented in Jira?
I appreciate any guidance on this,
You still need a listener, but you need to be more clever about the code you put as a condition.
You've put in "if custom field = X, then execute". What you need is a set of rules:
I'm not sure the rules can be built in to the stock listener, I suspect you will need to write your own listener script that includes them at the top.
My current condition is the following:
'requires attention' in cfValues['Security Impact']*.value
The custom field is of type checkbox.
Would you know how to add those rules. Most importantly how to check if the event caught says that my custom field value has been changed. I am just very lost when it comes to how to put code into conditions.
If this cant be done in a condition, in a custom Listener how do you check for:
And how do you create sub-tasks through code?
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!
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