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

getCustomFieldValue() always returns null in post function, although it works in Script Console


I'm running the latest JSD with Scriptrunner 6.7.0, and I have a simple portal like this:


I'm trying to retrieve the value from a Database Picker field called "Add Roles" in a post function set to trigger when the issue is resolved.

I have the following code, in the post function, to print the value of the field:

def customFieldManager = ComponentAccessor.getCustomFieldManager()

log.debug("Roles: ${issue.getCustomFieldValue(customFieldManager.getCustomFieldObjectsByName("Add Roles")[0])}")

 But when the post function runs, it always prints

Roles: null

despite the field is not empty.


However, when I try to do the same in Script Console, for example,

// Use the same issue
def issueKey = "PAP-39"
def issueManager = ComponentAccessor.getIssueManager()
def issue = issueManager.getIssueObject(issueKey)

log.debug("Roles: ${issue.getCustomFieldValue(customFieldManager.getCustomFieldObjectsByName("Add Roles")[0])}")

It successfully prints:

 Roles: [8, 9] // The options I selected in the Database Picker

 as expected.

Why does the same piece of code not work in post function, but in Script Console? I can confirm that the field is not hidden or read-only, and printing other fields in the post function using the same syntax always works.

1 answer

1 accepted

0 votes
Answer accepted

Found the answer here right after posting this...

It appears that I need to set the post function to be processed AFTER the issue is created and re-indexed, etc.


Hope this helps.

Suggest an answer

Log in or Sign up to answer

Atlassian Community Events