From a behaviour I couldn't access the value of a customfield
I finally managed to get access by
import com.atlassian.jira.ComponentAccessor
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.ComponentManager
import com.atlassian.jira.issue.CustomFieldManager
import com.atlassian.jira.issue.fields.CustomField
import com.atlassian.jira.issue.IssueManager
import com.atlassian.jira.issue.Issue
def cField = ComponentAccessor.getCustomFieldManager().getCustomFieldObjectByName("UserAuthFlag1")
def cFieldValue = underlyingIssue.getCustomFieldValue(cField).toString()
Now I want to update the same field and I am having issues - the code is saying to check that the declared type exists and if the method exists

for code
def cField = ComponentAccessor.getCustomFieldManager().getCustomFieldObjectByName("UserAuthFlag1")
def cFieldValue = underlyingIssue.getCustomFieldValue(cField).toString()
def cfConfig = cField.getRelevantConfig(underlyingIssue)
def value = ComponentAccessor.optionsManager.getOptions(cfConfig)?.find {
it.toString() == 'N'
}
underlyingIssue.setCustomFieldValue(cField, "fred")