Update Select List Custom Field using Jira Python

Rameez Rahman March 25, 2013

I have a custom field named "Detailed Status Two" with an id of 10100 which is a select list with optional values of "One", "Two", "Three" and "Four". Default value is "One".

I am writing a JIRA python script to update the value of this field conditionally. Say if the existing value is "One", it should be changed to "Three".

This is my code.

from jira.client import JIRA
jira_options={'server': 'http://localhost:8080'}
jira=JIRA(options=jira_options,basic_auth=('usrname','pwd'))

for issue in jira.search_issues(' cf[10100] = "One" '):
	issue.update(fields={'customfield_10100': 'Three'})

It's giving me the following error.

Traceback (most recent call last):
  File "test.py", line 11, in <module>
    issue.update(fields={'customfield_10100': 'Three'})
  File "C:\Python27\lib\site-packages\jira\resources.py", line 193, in update
    super(Issue, self).update(**data)
  File "C:\Python27\lib\site-packages\jira\resources.py", line 72, in update
    raise_on_error(r)
  File "C:\Python27\lib\site-packages\jira\exceptions.py", line 29, in raise_on_
error
    error = errorMessages[0]
IndexError: list index out of range

Could you please tell me what might be wrong?

I had used the same syntax for editing a custom field of text field and it had worked fine.

2 answers

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

1 vote
Rameez Rahman April 4, 2013

Adding the piece of code that finally worked for me.

issue.update(fields={'customfield_10100': {'value':'Two'}})

1 vote
Henning Tietgens
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
March 25, 2013

I don't understand python but I know, that the value of a select list is not the text but it's an option object. So you have to find the correct option object and update the field with it.

Henning

TAGS
AUG Leaders

Atlassian Community Events