Updating a costum field from select single option ( with Groovy and ScriptRunner )

Idan Sec
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
June 16, 2020

Hey guys,

 

I am new to JIRA and I am trying to update issue with a Groovy script. ( I use ScriptRunner with JIRA server. )

 

I wrote this simple function and I try to run it from the ScriptRunner console -

def Epic_Update_List_Field(epic_id, field_name, field_value)
{

def issue = ComponentAccessor.getIssueManager().getIssueByCurrentKey("$epic_id")
def select_singlechoice_field = ComponentAccessor.getCustomFieldManager().getCustomFieldObjectByName("$field_name")
select_singlechoice_field.updateValue(null, issue, new ModifiedValue("", (Object) getOptions(issue, select_singlechoice_field, ["$field_value"]).get(0)), new DefaultIssueChangeHolder())
}

 

The error I am getting is -

groovy.lang.MissingMethodException: No signature of method: first_epic.second_sync.getOptions() is applicable for argument types: (com.atlassian.jira.issue.IssueImpl, com.atlassian.jira.issue.fields.ImmutableCustomField...) values: [MAZ-87, SW Team, [WorkStation]]
at first_epic.second_sync.Epic_Update_List_Field(second_sync.groovy:519)
at first_epic.second_sync$Epic_Update_List_Field$1.callCurrent(Unknown Source)

 

It seems that the arguments I use for the getOptions() problem are wrong but I don't understand why.

I took the script from this post -

https://community.atlassian.com/t5/Agile-articles/Three-ways-to-update-an-issue-in-Jira-Java-Api/ba-p/736585

 

 

Any help would be appreciated. :)

 

Thanks in regard.

0 answers

Suggest an answer

Log in or Sign up to answer