I have custom field which takes a list of users , I am not able to update it with new values using jira python script. Please find below the method i have used
-> testuser = jira.user('rtracy')
(Pdb)
> /u/cm/sandbox/createG2jira_test.py(50)create_G2()
-> G2_issue.fields.customfield_14904.append(testuser)
(Pdb) testlist = G2_issue.fields.customfield_14904
(Pdb) p testlist
[<JIRA User: displayName='Jai Dembla', key='jdembla', name='jdembla'>, <JIRA User: displayName='Ramesh Babu Nidadavolu', key='rbabu', name='rbabu'>, <JIRA User: displayName='Rick Stoneking', key='rstoneking', name='rstoneking'>, <JIRA User: displayName='Vakil Arora', key='varora1', name='varora1'>]
(Pdb) testlist.append(testuser)
(Pdb) p testlist
[<JIRA User: displayName='Jai Dembla', key='jdembla', name='jdembla'>, <JIRA User: displayName='Ramesh Babu Nidadavolu', key='rbabu', name='rbabu'>, <JIRA User: displayName='Rick Stoneking', key='rstoneking', name='rstoneking'>, <JIRA User: displayName='Vakil Arora', key='varora1', name='varora1'>, <JIRA User: displayName='Robert Tracy', key='rtracy', name='rtracy'>]
(Pdb) G2_issue.update(fields={'customfield_14904': testlist } )
*** TypeError: Object of type 'User' is not JSON serializable
I am not sure what I am doing wrong
Hi!
the method expect to have a list of usernames instead the list of User Objects
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Yes I was able to resolve it as mentioned above by Gonchik. code snippet below:
issue.update( {"customfield_14904":[{"name" : "spolakoen"},{"name" : "rtrimbed"}]})
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I was trying to append user to the list without disrupting existing users in the list.
Same like your code
for issue in jira.search_issues('project = "xyz" and issuetype = Epic and status not in (Closed) and Testers in (rkapoor)', maxResults=100):
print('{}: {}'.format(issue.key, issue.fields.customfield_10600))
testuser = jira.user('rkapoor1')
testlist = issue.fields.customfield_10600
testlist.append(testuser)
testlist1 = ','.join([str(i) for i in testlist])
print(testlist1) //to check in console
issue.update(fields={"customfield_10600": testlist1})
It does not work at all.
Thanks
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You are again doing the same mistake which i did, ur taking an object of username... i suggest u directly pass the name string .
Ex: the line
testuser = jira.user('rkapoor1')
is the culprit. this will give u an object which is not useful. instead pass the name string rkapoor to name feild as is
issue.update(fields={"customfield_10600": [{"name" : "rkapoor1"}]}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Actually, this code replaces all the user with "rkapoor1".
issue.update(fields={"customfield_10600": [{"name" : "rkapoor1"}]}
Just wanted to append "rkapoor1", when JQL finds "rkapoor" in the Testers field (the Testers field might contain other users as well
SS:
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Ah that makes it easier, read the values from the field, assign it to a variable and then assign it back including new values appended in the list
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I would suggest u can google on how to assign values to list in python and from there use the above functions that's mentioned above
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Discover how Atlassian is revolutionizing service management with cutting-edge solutions for AI-powered support, HR Service Management, or DevOps connectivity.
Register here ⬇️Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.