Hi. Firstly, apologies if this is a bit basic - hopefully that'll translate into an easy answer!
I have a workflow set up to update a custom field to "No" whenever a certain status is transitioned to - that's performed via Scriptrunner post function (script is at the bottom of this post). Put simply, it doesn't work.
I have verrrrrrrrry little scripting experience so I've put this together from various sources. I've likewise looked at a couple of solutions already posted here but these haven't worked, which makes me think I'm missing something fundamental.
The custom field is called "RTS Buddying Complete?" and is a "Select list - single choice" type. The only choices are "No" which is the default, and "Yes."
When I transition to the appropriate status, I get a "Workflow Error" popup saying, "Error occurred while creating issue. This could be due to a plugin being incompatible with this version of JIRA. For more details please consult the logs, and see: http://confluence.atlassian.com/x/3McB java.lang.String cannot be cast to com.atlassian.jira.issue.customfields.option.Option
It seems that you have tried to perform an illegal workflow operation."
NB I can't open that link so I'm a bit stuck.
I've seen elsewhere that it might be because how I'm trying to update the field is incompatible with the select list, but - unless I'm missing something - I can't see what I need to do to get it to work.
Anyway, this is the script, which runs as a custom script post-function (inline script): I'm not even sure that I need the "Get custom field value" bit but I've included it here so you can see it in completion. It should be simple but it's really annoying me.
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.Issue
import com.atlassian.jira.issue.fields.CustomField
def customFieldManager = ComponentAccessor.getCustomFieldManager()
//get custom field object
def cfoBuddyComplete = customFieldManager.getCustomFieldObjectByName("RTS Buddying Complete?")
//get custom field value
def cfBuddyComplete = issue.getCustomFieldValue(cfoBuddyComplete)
//set value
issue.setCustomFieldValue(cfoBuddyComplete, 'No')