Hi,
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.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.