Forums

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

Is it possible to create sub-tasks based on custom field value during 'Edit' issue?

Vishali
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
May 29, 2013

After the issue is created, during 'edit' issue if the custom field value is updated, I want the sub-tasks to be created. Is this possible?

3 answers

1 accepted

2 votes
Answer accepted
Tsol
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
May 29, 2013

I think you should create a listener that catches the event of editing the custom field value.

Vishali
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
May 29, 2013

Kostas,

Do you have an idea on how to create a listener? I have tried using this but receiving erros:

com.atlassian.jira.event.issue.IssueEvent

Thanks,

JamieA
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
May 29, 2013

Yeah for "edit" operations you will need a listener... can you be more specific about the error you are getting.

You could use a Script Listeners -> Create sub-task, then specify a condition which checks if the value of your field has been newly changed to the value you care about.

Vishali
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
May 29, 2013

My custom field is a date field. When user chooses a date for this field (which will not be chosen while creating /transitioning a ticket, ), sub-tasks should be triggered. If I have to use Script listeners, What are the steps that I need to follow?

Thanks,

Vishali
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
May 29, 2013

I have tried to create a normal listener from Administration > Listeners the follwoing way.

Name: Listener for issue event

Class: com.atlassian.jira.event.issue.IssueEvent

Error: Exception loading class: [com.atlassian.jira.event.issue.IssueEvent doesn't have any satisfiable constructors. Unsatisfiable dependencies: [[interface com.atlassian.jira.issue.Issue, interface java.util.Map, interface com.atlassian.crowd.embedded.api.User, class java.lang.Long], [interface com.atlassian.jira.issue.Issue, interface com.atlassian.crowd.embedded.api.User, interface com.atlassian.jira.issue.comments.Comment, interface com.atlassian.jira.issue.worklog.Worklog, class org.ofbiz.core.entity.GenericValue, interface java.util.Map, class java.lang.Long], [interface com.atlassian.jira.issue.Issue, interface com.atlassian.crowd.embedded.api.User, interface com.atlassian.jira.issue.comments.Comment, interface com.atlassian.jira.issue.worklog.Worklog, class org.ofbiz.core.entity.GenericValue, interface java.util.Map, class java.lang.Long, boolean], [interface com.atlassian.jira.issue.Issue, interface java.util.Map, interface com.atlassian.crowd.embedded.api.User, class java.lang.Long, boolean], [interface com.atlassian.jira.issue.Issue, interface com.atlassian.crowd.embedded.api.User, interface com.atlassian.jira.issue.comments.Comment, interface com.atlassian.jira.issue.worklog.Worklog, class org.ofbiz.core.entity.GenericValue, interface java.util.Map, class java.lang.Long, boolean, boolean]]].


Name: Listener for issue event

Class: com.atlassian.jira.event.issue.IssueEventListener

Error:
Exception loading class: [Bad Access: 'com.atlassian.jira.event.issue.IssueEventListener' is not instantiable].

Tsol
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
May 29, 2013

Hey Vishali,

as Jamie said in the above comment you have to create a scripted listener using groovyrunner.

Script Listeneners > Create Sub-task

Vishali
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
May 30, 2013

Kostas,

As the custom field value will either have a date or null value, what should I set the condition to be?

Thanks,

Tsol
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
May 30, 2013

Hey Vishali,

what's the type of custom field that you are editing and fires the issue creation?

If it's a date custom field, i think condition should be something like:

cfValues['date_field'] == null || cfValues['date_field'] != null

If it's not a date field i think there should be a regex that validates if the entered values have date like format.

Hope that helps

Cheers

Commerce Mtg IT Dept
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
June 3, 2013

Kostas,

Thank you for your reply. I was busy with one of the releases and couldn't respond faster. Could you please provide me detailed steps on how to do this?

Thanks and best regards,

Tsol
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
June 3, 2013

Hey there,

Steps are the following:

  1. Log in as an administrator
  2. Go to Plugins tab (top left menu)
  3. From the Script Runner section choose Script Listeners
  4. From the options there, choose Create sub task

After that you have to choose the event that your listener cathes and under witch conditions your listener will execute the desired action.

Check previous comments.

Vishali
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
June 3, 2013

Kostas,

It worked for me. Thank you so much. Could you please tell me how do I assign each of the sub-task to a different assignee?

Regards,

Vishali
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
June 3, 2013

Kostas,

The problem is - every time that I update anything in the ticket, sub-tasks are getting created. Is there a groovy script which I can run only when a date is chosen from the custom field?

Tsol
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
June 4, 2013

Hey Vishali,

you should put a condition to the listener so it catches the event when condition is true.

e.g

cfValues['date_field'] == 'dd/mm/yyyy'

Add the condition when setting up the listener.

Cheers

Vishali
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
June 5, 2013

Kostas,

Thank you for the valuable input. But when the license posting date is updated more than once, then sub-tasks are created more than once. What should I do in this scenario?

Thanks,

Tsol
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
June 5, 2013

Hey Vishali,

in your existing condition add the following

&& issue.subTasks.size() <1

That way the listener will execute the action only when your issue doesn't have any subtask.

Test it first.

Hope that helps

Cheers

Vishali
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
June 6, 2013

Based on the value selected in the position field, number of sub-tasks being created varies. After this, my listener works to create the extra sub-tasks. So it need not necessarily be <1. So, how should I handle this scenario?

Will a groovy script work in such scenario?

Thanks,

Tsol
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
June 6, 2013

Hmm,

i think in your case a custom listener is the solution. If i'm not wrong, the current built in listener cannot control the number of created subtasks when issue is updated, one subtask is created every time that conditions are met.

Cheers

0 votes
Bob Swift
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
January 20, 2014

Once you start talking about doing this on a transition, then Create on Transition Plugin for JIRA applies and you can create multiple subtasks, etc... See How to create multiple issues for instance or one of the other similar pages.

0 votes
Darren Pegg
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
January 20, 2014

Hi,

Would the above work with some tweaking were I had a value of 3 within a number field on then on transition say "approved" to have 3 sub-tasks created?

Thanks

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events