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.
Atlassian Summit is an excellent opportunity for in-person support, training, and networking.Learn more
One of the newest products in the Microsoft family - Microsoft Teams, is a chat-based hub for teamwork that integrates all the people, content, and tools your team needs to be more engaged and ...
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
You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs