Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
Deleted user
0 / 0 points
badges earned

Your Points Tracker
  • Global
  • Feed

Badge for your thoughts?

You're enrolled in our new beta rewards program. Join our group to get the inside scoop and share your feedback.

Join group
Give the gift of kudos
You have 0 kudos available to give
Who do you want to recognize?
Why do you want to recognize them?
Great job appreciating your peers!
Check back soon to give more kudos.

Past Kudos Given
No kudos given
You haven't given any kudos yet. Share the love above and you'll see it here.

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

Why is my custom field empty during the "Create" Post Function?

We have a groovy script that takes the value stored in a custom field on a ProForma form(the field is a single-user picker).

On create the script should move that value to a different field (and does a bunch of other things).

However it fails every time, as Jira insists that the initial value of the custom field is null.

If we set the script to run on any transition after create, it works fine.  The script also works fine on existing tickets, using the Scriptrunner Console.

It’s as though the value of the custom field is not being set until well after the create transition has finished.

I simplified the script to just grabbing the value stored in the custom field, and logging still returns null.

Is there a way to ensure that the custom field value populates during the create transition?

import com.atlassian.jira.issue.CustomFieldManager
import com.atlassian.jira.issue.fields.CustomField
import com.atlassian.jira.issue.Issue
import org.apache.log4j.Logger
import org.apache.log4j.Level
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.user.util.UserManager


UserManager usrMgr = ComponentAccessor.getUserManager()

CustomFieldManager cfMgr = ComponentAccessor.getCustomFieldManager()

CustomField lobCf = cfMgr.getCustomFieldObject("customfield_12345")

log.debug "customfield value is"+ issue.getCustomFieldValue(lobCf)

1 answer

0 votes
Pete Preston Atlassian Team Jun 06, 2021

Hi @Kenneth McClean - Pete from the ProForma team here. Due to the order of events, it’s common for this kind of automation to read null data from ProForma. I know this can be avoided in ScriptRunner by adding a sleep() call to the beginning of the script to give enough time for ProForma data to save to Jira. I’m not as familiar with groovy, but think a similar approach could work. 

Hi Pete:


Thank you very much for your answer.  I'll give the sleep call a try.



@Pete PrestonI tried adding a sleep() of up to 15 seconds at the start of my script. It certainly delayed the running but it didn't seem to make a difference otherwise. Is there anything else I need to do to make this work?  I tried sticking the sleep call in different places in my script.



Pete Preston Atlassian Team Jun 07, 2021

Hi @Kenneth McClean -- hmm. I've asked around and don't have a great answer for you at the moment. I suggest connecting with and seeing they can shed more light on the order of operations.

Suggest an answer

Log in or Sign up to answer

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you