The Atlassian Community Forums are currently in read-only mode. We will be relaunching on a new platform on September 22 (read more here). We apologize for the extended downtime. For concerns or questions, please email communitymanagers@atlassian.com. See you on the other side, on the new Atlassian Community Forums! :)

×

Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Update jira issue customfield (text type) via python

Miguel Alfaro Andrés
February 22, 2024

Hello everyone,

 

We have an integration between our monit system and python, some of the code works (below) but fails when editing the field. No error is returned.

 

def add_jira_comment(self, issue_id, comment):
logging.info("Add comment for issue in Jira: %s " % issue_id)
jira = self.jira_obj()
jira.add_comment(issue_id, comment)


jira_issue = self.constr_issue_dict(issue_dict)

#This works nice
self.add_jira_comment(issue_dict['jira_id'], "[automatic] Alert was Forced OK")

# None of the below works
jira_issue.update(fields={'customfield_10121' : 'OK'})
jira_issue.update(customfield_10121='OK')


 

I've been looking for the issue through the forum trying a lot of fixes but no luck so far, anyone able to give some light to the issue? Im a bit lost rn.

3 answers

2 accepted

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

0 votes
Answer accepted
Miguel Alfaro Andrés
February 23, 2024

Now it works, new code for anyone that is as lost as i was:

jira = self.jira_obj()
issue = jira.issue('jira_id')
issue.update(fields={'customfield_10121': 'OK'})
0 votes
Answer accepted
Miguel Alfaro Andrés
February 22, 2024

Btw, the customfield is editable by anyone, so i guess there's no problem on the permissions department

0 votes
Miguel Alfaro Andrés
February 22, 2024

I have tried with all these so far (no results):

#custom_field_value = "OK"
#field = "customfield_10121"
#jira_issue.update(fields={'customfield_10121': 'OK'})
#issue.update(fields={'customfield_10121': 'New value'})
#jira_issue.update({"customfield_10121":[{"name" : "OK"}]})
#jira_issue.update(fields={"customfield_10121": custom_field_value})
#jira_issue.update(fields={'customfield_10121' : 'OK'})
#jira_issue.update(customfield_10121='OK')
#jira_issue.update(customfield_10121={'name': custom_field_value})