Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Conditions when creating a sub task, as well as validating and updating custom fields

Joseph December 18, 2018

Hey guys,

I already tried to read my way through Adaptavist documentation and a couple of your threads here in the community but I honestly don't know where to start.

Let me explain my idea first:

I have a main task with a custom number field (A). One can create a sub task with a different custom number field (B) when certain conditions are met.

  • The main task is open
  • The user is allowed to create sub tasks
  • The value of B is the same or less than the value of A

Once the sub task is successfully created the Value of A needs to be updated. It should show B subtracted from A.

So, visually explained: The parent task field A has a value of 50. After a successfull creation of a sub task with B=20, the value of A should be reduced to 30.

If a sub task is changed later on, it should also check the conditions.

If a sub tasks is "cancelled", the value of B needs to be added to A again.

First I thought I use Scripted Fields to solve this problem. But I read - I believe here on the community - that this will produce a heavy load every time the task is handled by the system (index, search...).  My search brought me to ScriptRunners "Listeners" but I do not know how to start this off properly. It sounds like a custom listener in combination with an update.issue() event sounds like the way to go.

Any chance that you can help me out? Or point me in the right direction? I can usually read scripts/code and understand it, but writing my own seems to be quite the challenge.

1 answer

0 votes
Patrick Richter December 19, 2018

Do you have Jira Suite Utilities licensed?

If you do, you might get cracking by just using workflow mechanics.

Option 1: You create a workflow transition on the parent issue itself, having a status like "Still valid" and a transition from this status to itself. On this transition, you could create a corresponding subtask and do the math on your custom field with some groovy script via post functions. You could even add a condition on subtask creation making sure *A* is still > 0.

Option 2: You let the user create the subtask themselves and use groovy script to identify the parent issue and update *A*, again on a workflow transition of your choice.

Both options should only crunch numbers once.

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events