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.
I am trying to create a Custom Listener that fires on the SprintStartedEvent.
What I want for the outcome is when a Sprint is started the value that is in the custom field "Planned Assignee" which is a single user picker field will be copied into the Assignee field.
I am not sure how to get this started. I haven't been able to find any previous questions asked that are helpful in this situation.
Thanks for links to the documentation. It has not proved to be terribly helpful.
This is the script that I have cobbled together looking at various examples of things that are sorta close.
You can see that the event.issue is causing a problem and that is what the log references:
2022-05-05 10:50:35,729 ERROR [runner.AbstractScriptListener]: *************************************************************************************
2022-05-05 10:50:35,729 ERROR [runner.AbstractScriptListener]: Script function failed on event: com.atlassian.greenhopper.api.events.sprint.SprintStartedEvent, file: null
groovy.lang.MissingPropertyException: No such property: issue for class: com.atlassian.greenhopper.api.events.sprint.SprintStartedEvent
at Script993.run(Script993.groovy:7)
I am not sure how to get around that. I can't even start to see how the rest of the code is messed up while that is erroring.
I see I did not mention this in the OP, I am using Jira Data Center 8.20.1. Looks like ScriptRunner is on 6.49.
Yes the event is a sprint event and not an issue event. You need to get the issues out of the sprint event as per the example in the Library (although that's for the closed event the logic is basically the same).
So this line here the value would be null. def issue = event.issue as issue
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
So in the example, everything above line 21 if (sprintData) is somehow grabbing the issues from the Sprint. Okay. I still don't understand at all how I would call the custom field "Planned Assignee" and use that to populate the Assignee field because the only way I know how to do that is using script with issue in it (issue.assignee, event.issue, etc).
If the example is somehow showing that then I do not understand how.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I'm really sorry I can't test for you but you need to try something along these lines.
import com.atlassian.greenhopper.service.rapid.view.RapidViewService
import com.atlassian.greenhopper.service.sprint.Sprint
import com.atlassian.greenhopper.web.rapid.chart.HistoricSprintDataFactory
import com.atlassian.jira.component.ComponentAccessor
import com.onresolve.scriptrunner.runner.customisers.PluginModuleCompilationCustomiser
import com.onresolve.scriptrunner.runner.customisers.WithPlugin
import com.atlassian.jira.workflow.TransitionOptions
@WithPlugin("com.pyxis.greenhopper.jira")
def historicSprintDataFactory = PluginModuleCompilationCustomiser.getGreenHopperBean(HistoricSprintDataFactory)
def rapidViewService = PluginModuleCompilationCustomiser.getGreenHopperBean(RapidViewService)
def user = ComponentAccessor.jiraAuthenticationContext.getLoggedInUser()
def sprint = event.sprint as Sprint
def sprintState = sprint.state
if (sprintState == Sprint.State.ACTIVE) {
def view = rapidViewService.getRapidView(user, sprint.rapidViewId).value
def sprintContents = historicSprintDataFactory.getSprintOriginalContents(user, view, sprint)
def sprintData = sprintContents.value
def issueService = ComponentAccessor.getIssueService()
if (sprintData) {
def issues = sprintData.contents.issuesNotCompletedInCurrentSprint
issues.each { issue ->
def issueId = issue.id
def sourceField = customFieldManager.getCustomFieldObjectByName("Planned Assignee")
// put the rest of your code here
}
}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @Chelsea welcome to the community.
I'd suggest you start here, there's lots of examples.
Jira Server:
Jira Cloud:
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.