Reputation: 168
I have a custom field named "Status" 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 "Two".
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': 'Two'})
It's giving me the following error.
Traceback (most recent call last):
File "test.py", line 11, in <module>
issue.update(fields={'customfield_10100': 'Two'})
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 type text field and it had worked fine.
Upvotes: 4
Views: 4757
Reputation: 101
Try it like this:
issue.update(fields={'customfield_10100': {'value':'Two'}})
or like this:
issue.update(fields={'customfield_10100': {'value','Two'}})
I am not sure which one will work out for you because I never worked with Python, but one of them should work.
Upvotes: 5