Need some help and I am stuck in this issue.
When I do ComponentAccessor.getCustomFieldManager().getCustomFieldObject I get back ImmutableCustomField with which I am not able to read or update the custom field value.
def customFieldManager = ComponentAccessor.getCustomFieldManager();
CustomField cField = ComponentAccessor.getCustomFieldManager().getCustomFieldObject("customfield_10011")
String val = getCustomFieldValue(cField)
output when I run in console:
2017-11-21 11:47:52,415 INFO [acme.CreateSubtask]: class com.atlassian.jira.issue.fields.ImmutableCustomField
2017-11-21 11:47:52,418 WARN [common.UserScriptEndpoint]: Script console script failed: groovy.lang.MissingMethodException: No signature of method: org.codehaus.groovy.jsr223.GroovyScriptEngineImpl.getCustomFieldValue() is applicable for argument types: (com.atlassian.jira.issue.fields.ImmutableCustomField) values: [Chargeback Status] at Script243.run(Script243.groovy:40)
Ahh!! Figured it out myself.
Solution: You need to have the reference to the issue always either in console or in post function. Only then it works and updates my CustomField.
I don't know behind scenes what is going on but when you do
getCustomFieldValue(cField) --> Ouputs the error above
issue.getCustomFieldValue(cField) ---> Gets me the actual value
What led to this confusion in first place is I kept reading docs where people said there is no need to use "issue" if you are in post function as the scriptrunner already has context of the "issue" but apparently that isn't a sweet route for me.
Atlas Camp is our developer event which will take place in Barcelona, Spain from the 6th -7th of September . This is a great opportunity to meet other developers and get n...
Connect with like-minded Atlassian users at free events near you!Find a group
Connect with like-minded Atlassian users at free events near you!
Unfortunately there are no AUG chapters near you at the moment.Start an AUG