Jira Automation firing Scriptrunner script action

Hey all,

It’s probably just something ■■■■■■ thing I am missing or overseeing.

I have jira automation watching for a fieldchange which then fires an Scriptrunner script which should fill a radiobuttons customfield based on a string.

// Get fields
def issue                    = issueManager.getIssueObject(issueKey)
def TypeCF                   = cfm.getCustomFieldObject("customfield_11215")

// Get values
def Type                     = "String"

// Get TypeCF options
def TypeCFconfig             = TypeCF.getRelevantConfig(issue)
def TypeCFoptions            = optionsManager.getAllOptions()
def TypeCFoption             = TypeCFoptions.find { it.value == Type }

issue.update {
    issue.setCustomFieldValue(TypeCF, TypeCFoption)
}

Within the Script Console this outputs the issuekey, but within the automation rule I am getting
No signature of method: com.adaptavist.hapi.jira.issues.delegate.IssueUpdateDelegate.setCustomFieldValue() is applicable for argument types: (com.atlassian.jira.issue.fields.ImmutableCustomField, com.atlassian.jira.issue.customfields.option.LazyLoadedOption) values: [Type, String]

Hope someone can help.

1 Like

Hi,
Which version of scriptrunner are you using?
Because you are using a deprecated method (it’s recommendable to don’t use it), getIssueObject()
And you are trying to use HAPI issue.update but in a incorrect way.

Check this video about using HAPI.

1 Like

Heya imadero,

We’re on 8.9.0

I am using issue.update in another automation rule, just not with customfields, which does work:

issue.update {
    setAssignee(user)
    setDescription {
        prepend('sometext.')
    }
}

I will try getIssueObject() and watch the video and come back to you.

I got it working, thanks to the video. Apparently you simply have to call on the CustomField just by a string and not getCustomFieldObject

// Get fields
def issue                    = Issues.getByKey('TEST-1')

// Get values
def Type                     = "String"

issue.update {
    setCustomFieldValue('CustomFieldName', Type)
}

Really happy to hear that you solved it! If you can, please mark the question as answered to help other people.

Thanks, Ivan.