Search code examples
pythonjira

Python not updating Jira Cloud Field (text editable)


This is the code, not returning any error code:

def add_jira_comment(self, issue_id, comment):
    """
        Description:
        Adds jira comment.
    """
    logging.info("Add comment for issue in Jira: %s " % issue_id)
    jira = self.jira_obj()
    jira.add_comment(issue_id, comment)
def jira_set_forced_ok(self):
...
query_check_to_send = "select * from alerts where forced_ok = '1' and forced_is_checked is null and sync_error_counter < 5 and priority != 'Mail'"
rows = self.execute_query(query_check_to_send).fetchall()
for issue in rows:
issue_dict = dict(issue)
custom_field_id = 'customfield_10121'
value = 'OK'
update_payload = {
'fields': {
custom_field_id: value
}
}
self.jira.update_issue(issue_dict['jira_id'], fields=update_payload['fields'])
self.add_jira_comment(issue_dict['jira_id'], "[automatic] Alert was Forced OK")

The field update aint working, the comment does, i've tried some more stuff, but none of it works.

Mention this is a jira cloud instance, the field itself is text editable, and anyone can edit it (i know the python connects to the jira issue beacuse the comment part does work)

We got a customfield (text editable) that should update, it does not


Solution

  • It was a syntax error:

    issue = jira.issue('jira_id')

    issue.update(fields={'customfield_10121': 'OK'})