I have several scripted fields and until recently they behaved quite like Custom fields, when I needed to grab their values in the listener or postfunction groovy. However, as of recent upgrade (I am not quite sure, which version) this is no longer working and in fact the script crashes when I try to treat Scripted Fields like Custom Fields. Adaptavist documentation is silent on how to use scripted fields in a listener code. Please help with a sample use example. Thanks!
Hello,
Could you please provide a piece of your code and the errors?
Here goes. This is executed in the console, first field is regular custom field and the second is Adaptavist Scripted Field:
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.Issue
import com.atlassian.jira.issue.IssueManager
import com.atlassian.jira.issue.CustomFieldManager
def im = ComponentAccessor.issueManager
def issue = im.getIssueObject("AAABBB")
log.warn("Executing for issue " + issue.key)
def cfv = getCustomFieldValue (issue, "customfield_XXXXX")
log.warn "Custom Field = "+cfv
def sfv = getCustomFieldValue (issue, "customfield_YYYYY")
log.warn "Scripted Field = "+sfv
It logs:
2018-06-26 15:36:44,793 WARN [runner.ScriptRunnerImpl]: Executing for issue AAABBB 2018-06-26 15:36:44,794 WARN [runner.ScriptRunnerImpl]: Custom Field = My Value
It doesn't print anything beyond that, leading me to believe that it crashes while trying to extract value from the Scripted field
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
What is the getCustomFieldValue() method?
You should query a value either
issue.getCustomFieldValue(ComponentAccessor.getCustomFieldManager().getCustomFieldObjectsByName().first(customfield_YYYYY))
or
ComponentAccessor.getCustomFieldManager().getCustomFieldObjectsByName().first(customfield_YYYYY).getValue(issue)
Try the second one for the scripted field.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.