Single-select returning null value in groovy script

Jason Adam October 22, 2018

I have the following in a groovy script:

def acceptField = customFieldManager.getCustomFieldObjectByName("Accept CR")
log.error("AcceptField: " + acceptField)
def acceptValue = mutableIssue.getCustomFieldValue(acceptField)
log.error("AcceptValue: " + acceptValue)
def groupField = customFieldManager.getCustomFieldObjectByName("Review Group")
log.error("GroupField: " + groupField)
def groupId = mutableIssue.getCustomFieldValue(groupField)
log.error("Group ID: " + groupId)

 

Accept CR and Review Group are both single-select fields.  Accept CR has only "Accept" and "Decline" as options, "Review Group" has a list of group ids.

 

When the script runs, I get this in the output:

2018-10-22 18:39:06,426 ERROR [workflow.ScriptWorkflowFunction]: AcceptField: Accept CR
2018-10-22 18:39:06,427 ERROR [workflow.ScriptWorkflowFunction]: AcceptValue: null
2018-10-22 18:39:06,427 ERROR [workflow.ScriptWorkflowFunction]: GroupField: Review Group
2018-10-22 18:39:06,427 ERROR [workflow.ScriptWorkflowFunction]: Group ID: Additional Reviewer

 

There's nothing I can see that is different between these fields.  They're on the same screen, same types of configurations, etc.  But no  matter what I do, Accept CR always returns null.

 

Any idea where to look to see what is wrong here?

 

Thanks!

 

2 answers

1 accepted

1 vote
Answer accepted
Elifcan Cakmak
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.
October 22, 2018

Hello,

Are you sure that Accept CR custom field is filled on that specific issue that you test? Because when I test your code, it works just fine and returns the values. If Accept CR customfield is empty on the issue, it returns null as expected. So your code seems to be correct.

Selection_067.pngRegards,

Jason Adam October 22, 2018

Grrrr that was it, found that a script further up in the post-function chain was clearing out  those values for the next time someone hits that transition (it's a loop back transition).  I moved the clearing out piece into its own script and made that the last script called.  Thanks for the second pair of eyes lol

0 votes
Elifcan Cakmak
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.
October 22, 2018

Glad to help, sometimes a second set of eyes is all you need :) 

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events