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?
UserManager usrMgr = ComponentAccessor.getUserManager()
CustomFieldManager cfMgr = ComponentAccessor.getCustomFieldManager()
CustomField lobCf = cfMgr.getCustomFieldObject("customfield_12345")
log.debug "customfield value is"+ issue.getCustomFieldValue(lobCf)
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.
@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.
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