You're on your way to the next level! Join the Kudos program to earn points and save your progress.
Level 1: Seed
25 / 150 points
Next: Root
1 badge earned
Challenges come and go, but your rewards stay with you. Do more to earn more!
What goes around comes around! Share the love by gifting kudos to your peers.
Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!
Join now to unlock these features and more
The Atlassian Community can help you and your team get more value out of Atlassian products and practices.
Hi
I'm using the below Listener script to inherit the Epic custom field "Business clinetPO" values to the child ticket. I want set some conditions here that,
Thanks,
Prabhu
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.event.type.EventDispatchOption
import com.atlassian.jira.issue.Issue
import com.atlassian.jira.issue.MutableIssue
def issue = event.issue as MutableIssue
def loggedInUser = ComponentAccessor.jiraAuthenticationContext.loggedInUser
def customFieldManager = ComponentAccessor.customFieldManager
def issueManager = ComponentAccessor.issueManager
def issueLinkManager = ComponentAccessor.issueLinkManager
def BusinessClientPO = customFieldManager.getCustomFieldObjectsByName('Business ClientPO').first()
def epicLink = customFieldManager.getCustomFieldObjectsByName('Epic Link').first()
def BusinessClientPOValue = issue.getCustomFieldValue(BusinessClientPO)
def subTasks = [] as ArrayList<Issue>
if (issue.issueType.name == 'Epic' && issue) {
def links = issueLinkManager.getOutwardLinks(issue.id)
links.each {
def destinationIssue = it.destinationObject as MutableIssue
destinationIssue.setCustomFieldValue(BusinessClientPO, BusinessClientPOValue)
issueManager.updateIssue(loggedInUser, destinationIssue, EventDispatchOption.DO_NOT_DISPATCH,false)
destinationIssue.subTaskObjects.findAll
{ subTasks.addAll(it) }
}
} else if(issue.getCustomFieldValue(epicLink)) {
def links = issueLinkManager.getInwardLinks(issue.id)
links.each
{ issue.setCustomFieldValue(BusinessClientPO, it.sourceObject.getCustomFieldValue(BusinessClientPO) ) issueManager.updateIssue(loggedInUser, issue, EventDispatchOption.DO_NOT_DISPATCH,false) }
} else if(issue.isSubTask())
{ subTasks.addAll(issue) }
subTasks.each
{ def subTask = it as MutableIssue subTask.setCustomFieldValue(BusinessClientPO, it.parentObject.getCustomFieldValue(BusinessClientPO)) issueManager.updateIssue(loggedInUser, subTask, EventDispatchOption.DO_NOT_DISPATCH,false) }
Hello @Prabakaran P ,
assuming your script works, you would just need to add a if clause to check if the value is select (also assuming your field is a single select list) :
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.event.type.EventDispatchOption
import com.atlassian.jira.issue.Issue
import com.atlassian.jira.issue.MutableIssue
def issue = event.issue as MutableIssue
def loggedInUser = ComponentAccessor.jiraAuthenticationContext.loggedInUser
def customFieldManager = ComponentAccessor.customFieldManager
def issueManager = ComponentAccessor.issueManager
def issueLinkManager = ComponentAccessor.issueLinkManager
def BusinessClientPO = customFieldManager.getCustomFieldObjectsByName('Business ClientPO').first()
def epicLink = customFieldManager.getCustomFieldObjectsByName('Epic Link').first()
def BusinessClientPOValue = issue.getCustomFieldValue(BusinessClientPO)
def subTasks = [] as ArrayList<Issue>
if (BusinessClientPOValue.getValue() in ["Prospect","Unknown"]) {
if (
if (issue.issueType.name == 'Epic' && issue) {
def links = issueLinkManager.getOutwardLinks(issue.id)
links.each {
def destinationIssue = it.destinationObject as MutableIssue
destinationIssue.setCustomFieldValue(BusinessClientPO, BusinessClientPOValue)
issueManager.updateIssue(loggedInUser, destinationIssue, EventDispatchOption.DO_NOT_DISPATCH,false)
destinationIssue.subTaskObjects.findAll
{ subTasks.addAll(it) }
}
} else if(issue.getCustomFieldValue(epicLink)) {
def links = issueLinkManager.getInwardLinks(issue.id)
links.each
{ issue.setCustomFieldValue(BusinessClientPO, it.sourceObject.getCustomFieldValue(BusinessClientPO) ) issueManager.updateIssue(loggedInUser, issue, EventDispatchOption.DO_NOT_DISPATCH,false) }
} else if(issue.isSubTask())
{ subTasks.addAll(issue) }
subTasks.each
{ def subTask = it as MutableIssue subTask.setCustomFieldValue(BusinessClientPO, it.parentObject.getCustomFieldValue(BusinessClientPO)) issueManager.updateIssue(loggedInUser, subTask, EventDispatchOption.DO_NOT_DISPATCH,false) }
}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.