Hello Everyone!
I have been pounding my head against a wall for days just trying to learn how to do a few basic things in a groovy script. I have had some luck with post transition scripts, but now I am trying to do something that seems like it should be simple in an automation script. I am just trying to set a value on a field - in this case a checkbox (and eventually a few other custom fields).
I have tried at least 30 examples from here on the forum, but all show me an error on the setCustomFieldValue and I do not understand why. I have cut my code down to the bare minimum to try and get it working, so just the imports, the definitions, and the field I want to set. The set line (which I have tried at least 7 variations of) always has the red mark indicating an error. I am suspecting this is something simple, but has been buried in other examples so that my searches never find the small thing I need.
I have this in a scriptrunner automation set to run when the issue created and when I use a specific entry in the Summary, It is entered under a "Execute a ScriptRunner script":
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.event.type.EventDispatchOption
def customFieldManager = ComponentAccessor.getCustomFieldManager()
def cf_VisTicket = customFieldManager.getCustomFieldObjectByName("HELP: Visible Ticket")
issue.setCustomFieldValue(cf_VisTicket, "Visible Ticket")