I am using jira-python API v0.13. (Snippets below exclude jira client set-up scaffolding for brevity.)
I need to update a multi-checkbox field which has NO VALUE currently, to make one of the boxes "checked".
Multi-checkbox field name = Flags
Values = Customer, Partner, Other
I've initalized the connection with JIRA successfully. I can get data from this multi-checkbox field for a record that HAS values for this multi-checkbox:
>>> i = jira.issue('ABC-123') >>> f = i.fields.customfield_10060 >>> [v.value for v in reversed(f)] [u'Customer',u'Partner']
However, when I am unable to update the field to insert a new value. Specifically, I am attempting to push values into a record that has NO VALUES set for the checkbox yet (don't know if that's the problem or not, since I can't insert values for one that has one or more values, either!)
This doesn't work:
>>> i = jira.issue('ABC-155') >>> i.update(fields={'customfield_10060': {'value': 'Customer'}})
error is jira.exceptions.JIRAError: HTTP 400: "{u'Flags': u'data was not an array'}"
Neither does this:
>>> i = jira.issue('ABC-155') >>> i.update(fields={'customfield_10060': ['value', 'Customer']})
error is jira.exceptions.JIRAError: HTTP 400: "{u'Flags': u'expected Object'}"
Comments / suggestions appreciated.
Community moderators have prevented the ability to post new answers.
You should pass array of objects as specified here - https://developer.atlassian.com/display/JIRADEV/JIRA+REST+API+Example+-+Create+Issue#JIRARESTAPIExample-CreateIssue-MultiSelect
i.update(fields={'customfield_10060': [{'value': 'Customer'}]})
Perfect!
Thanks so much, Boris. That link to the dev wiki is very helpful indeed!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
@Boris Georgiev [Botron]
The problem with this approach is that the update will overwrite previous values.
Assuming we have a multiple select checkbox custom_field:
[ ] option1
[ ] option2
[x] option3
after update
i.update(fields={'customfield_10060': [{'value': 'option1'}]})
field will be
[x] option1
[ ] option2
[ ] option3
[x] option1
[ ] option2
[x] option3
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Try getting the value of the field first, then make your updates and last - pass the value back to JIRA for update
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
@Boris Georgiev [Botron], I am almost there...
for issue in issues: print "hi all, i am here" selected_values = issue.fields.customfield_13336 values = "[" for value in selected_values: values += "{{'value': '{0}'}},".format(value) values = values[:-1] values += "]" #issue.update(fields={'customfield_13336':[{'value':hostOption} ,{'value':targetOption}]}) issue.update(fields={'customfield_13336':values})
The error:
response text = {"errorMessages":[],"errors":{"Target Environment":"data was not an array"}}
I basically get all values and store in a string, then I try to provide over issue.update(xxx).
Do you have an idea how I can compose a variable array of objects with the values to be provided to issue.update?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
This should work, applying to your example here :
... selected_values = issue.fields.customfield_13336 values = []
for value in selected_values: values += [{'value':str(value)}] issue.update(fields={'customfield_13336':values})
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.