0

I have been trying to append user to the existing multi-user picker field without replacing users in it.

Ex: The Jira JQL finds the user rkapoor in the Testers field, then append rkapoor1 to the Testers field

Note: The Testers field might contain other users along with rkapoor (just wanted append, not to replace other users)

for issue in jira.search_issues('project = "ABC" and issuetype = Epic and status not in (Closed) and Testers in (rkapoor)', maxResults=100):
testuser = jira.user('rkapoor1')
testlist = issue.fields.customfield_10600
testlist.append(testuser)
issue.update(fields={"customfield_10600": [testlist]})

Console error:

Traceback (most recent call last): File "Jiratest1.py", line 32, in issue.update(fields={"customfield_10600": [testlist]}) File "C:\Python\Python38-32\lib\site-packages\jira\resources.py", line 485, in update super(Issue, self).update(async_=async_, jira=jira, notify=notify, fields=data) File "C:\Python\Python38-32\lib\site-packages\jira\resources.py", line 225, in update data = json.dumps(data) File "C:\Python\Python38-32\lib\json_init_.py", line 231, in dumps`` return _default_encoder.encode(obj) File "C:\Python\Python38-32\lib\json\encoder.py", line 199, in encode chunks = self.iterencode(o, _one_shot=True) File "C:\Python\Python38-32\lib\json\encoder.py", line 257, in iterencode return _iterencode(o, 0) File "C:\Python\Python38-32\lib\json\encoder.py", line 179, in default raise TypeError(f'Object of type {o.class.name} ' TypeError: Object of type User is not JSON serializable

Any help would be appreciated.

1 Answers1

0

Found the solution,

testuser = jira.user('rkapoor1')
testlist = issue.fields.customfield_10600
testlist.append(testuser)
new_assignees = [{"name": str(u.name)} for u in testlist] 
issue.update(fields={"customfield_10600": new_assignees})