When users create a sub-task, I want a custom field value on the sub-task to default to the value on the parent when the sub-task screen is displayed. How do I configure/enable/script this?
Thanks for the suggestions, guys. I ended up solving this a little differently.
I originally had the field as required so I wanted the value set when the screen opened. After rethinking things, I made the field optional and used the JIRA Miscellaneous Workflow Functions plugin to create a post function that sets the field to the value from the parent.
have you considered the case where the parent is updated? should the child update as well?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Is this possible? The below code works if I update the Subtask, but not if I update the parent. If I change the parent, I want all subtasks to be updated.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
jos is right. created custom code can be time consuming so a plugin that speeds that along is ideal. if you hell bent on crafting the custom code though, i created a listener in groovy that ensures the fixversion of the children always matches the fixversion of the parent. you'll find it below if you care to revise to fit your needs.
package com.custom import com.atlassian.jira.event.issue.AbstractIssueEventListener import com.atlassian.jira.event.issue.IssueEvent import com.atlassian.jira.issue.MutableIssue import com.atlassian.jira.issue.Issue import com.atlassian.jira.ComponentManager import com.atlassian.jira.component.ComponentAccessor import com.atlassian.jira.user.util.UserManager import com.atlassian.jira.issue.IssueManager import com.atlassian.jira.issue.IssueInputParameters import com.atlassian.jira.security.JiraAuthenticationContext import com.atlassian.jira.project.version.Version import com.atlassian.jira.event.type.EventDispatchOption import org.apache.log4j.Category import com.atlassian.jira.issue.changehistory.ChangeHistoryManager import com.atlassian.jira.issue.history.ChangeItemBean import java.util.Calendar import java.util.Date import java.sql.Timestamp class TaskVersionListener extends AbstractIssueEventListener { Category log = Category.getInstance(TaskVersionListener.class) @Override void issueUpdated (IssueEvent event) { log.setLevel(org.apache.log4j.Level.WARN) log.debug ("---- TaskVersionListener starts -----") log.debug ("issue: ${event.issue} || task: ${event.issue.isSubTask()}") // method configuration Calendar cal = Calendar.getInstance() cal.add(Calendar.SECOND, -30) Date date = cal.getTime() Timestamp threshhold = date.toTimestamp() IssueManager issueManager = ComponentAccessor.getIssueManager() UserManager userManager = ComponentAccessor.getUserManager() ChangeHistoryManager changeHistoryManager = ComponentAccessor.getChangeHistoryManager() if (!event.issue.isSubTask()) { List <ChangeItemBean> changeItemBeans = changeHistoryManager.getChangeItemsForField(event.issue,"Fix Version") changeItemBeans.each { item -> log.debug ("Fix Version created at ${item.getCreated()} with threshhold of $threshhold") if (item.getCreated().after(threshhold)) { log.debug ("green light for item above!") event.issue.getSubTaskObjects().each { t -> if (!t.getStatusObject().getName().equals("Done")) { MutableIssue myIssue = t myIssue.setFixVersions(event.issue.getFixVersions()) issueManager.updateIssue(userManager.getUser("automation"), myIssue, EventDispatchOption.DO_NOT_DISPATCH, false) } } } } } else { List <ChangeItemBean> changeItemBeans = changeHistoryManager.getChangeItemsForField(event.issue,"status") changeItemBeans.each { item -> log.debug ("created at ${item.getCreated()} with threshhold of $threshhold") if (item.getCreated().after(threshhold) && item.getFromString().equals("Done")) { log.debug ("green light for item above!") MutableIssue myIssue = event.issue myIssue.setFixVersions(event.issue.getParentObject().getFixVersions()) issueManager.updateIssue(userManager.getUser("automation"), myIssue, EventDispatchOption.DO_NOT_DISPATCH, false) } } } log.debug ("---- TaskVersionListener ends ------") } }
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
geting/setting customfields can be a bit involved in java/groovy code, so you could use my add-on's configurable copy Listener for that: Slingshot Updatefields.
cheers, Jos
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.