Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Earn badges and make progress

You're on your way to the next level! Join the Kudos program to earn points and save your progress.

Deleted user Avatar
Deleted user

Level 1: Seed

25 / 150 points

Next: Root


1 badge earned


Participate in fun challenges

Challenges come and go, but your rewards stay with you. Do more to earn more!


Gift kudos to your peers

What goes around comes around! Share the love by gifting kudos to your peers.


Rise up in the ranks

Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!


Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
Community Members
Community Events
Community Groups

ScriptRunner post-function: error when trying to set custom field value


Hi there!

I'm trying to get an active sprint name from a given board in the post-function and write a sprint name to a custom field. 

Here is the script that I use in the post-function:

import com.atlassian.greenhopper.service.rapid.view.RapidViewService
import com.atlassian.greenhopper.service.sprint.SprintIssueService
import com.atlassian.greenhopper.service.sprint.SprintManager
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.Issue
import com.onresolve.scriptrunner.runner.customisers.JiraAgileBean
import com.onresolve.scriptrunner.runner.customisers.WithPlugin
import com.atlassian.jira.ComponentManager
import com.atlassian.jira.issue.fields.CustomField
import com.atlassian.jira.issue.CustomFieldManager

* Configurable section
// Enter the name of the board to which you want to add the issue to the first active sprint
def rapidBoardId = 619
def cfm = ComponentAccessor.getCustomFieldManager()
def item = cfm.getCustomFieldObjectByName("Item")
def active

log.error("item: " + item)

RapidViewService rapidViewService

SprintIssueService sprintIssueService

SprintManager sprintManager

Issue issue = ComponentAccessor.getIssueManager().getIssueObject("your issue key")

def loggedInUser = ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser()
def view = rapidViewService.getRapidView(loggedInUser, rapidBoardId).getValue()

if (! view) {
log.warn("No view with this ID found")

def sprints = sprintManager.getSprintsForView(view).getValue()
def activeSprint = sprints.find { }
log.debug activeSprint

if (activeSprint) {
active =
issue.setCustomFieldValue(item, active)
else { ("No active sprints were found for board: ${}")

As a result of post-function I get an error:

2018-12-12 04:19:57,388 ERROR [workflow.ScriptWorkflowFunction]: Script function failed on issue: SM-964, actionId: 61, file: <inline script>
java.lang.NullPointerException: Cannot invoke method setCustomFieldValue() on null object


Please help me to understand what is wrong in the script ans how to make it work. 

Thank you! 

1 answer

1 accepted

1 vote
Answer accepted
Vasiliy Zverev
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.
Dec 12, 2018

Hi Elena!

It seems that you call this into Script console. 

Variable issue is defined as current issue when code is used into postfunction.

You need to use correct issue key here

Issue issue = ComponentAccessor.getIssueManager().getIssueObject("your issue key")

 You also need to save your changes into DB when use script console with IssueManager.updateIssue() method. 

Suggest an answer

Log in or Sign up to answer
AUG Leaders

Atlassian Community Events