Hi, I was wondering if someone could help explain how I would be able to update a custom field using the jira python api.
Normally, this custom field is added manually by typing the item key to be attached into the search bar, then selecting the item that appears from the drop-down menu. Once selected, the item appears as a box under the custom field. After saving, the same linked item can be viewed after closing and re-opening the edit menu.
I attempted to update the custom field using
new_issue.update(fields = {"[custom field id]": { "key": feature_issue.key }})
but the field doesn't seem to link the given key to an actual item as the selection disappears upon re-opening the edit menu
Hopefully my drawings below can explain my ask. Any guidance is appreciated, thanks!
Hello @Yang, Nini
Welcome to the Atlassian community.
What is the field type of the custom field? Is the custom field a multi-select Issue Picker field?
For a multiple selection list I believe you need to declare each value you want to add as a pair inside of curly braces and use "value" as the key.
{"value": feature_issue.key}
And since you might have multiple values you would separate them with commas:
{"value": feature_issue.key}, {"value": another_issue.key}
And encompass the entire list in square brackets
[{"value": feature_issue.key}, {"value": another_issue.key}]
If you have only one value to add you still need to encompass it in brackets.
[{"value": feature_issue.key}]
So, try this:
new_issue.update(fields = {"[custom field id]": [{ "value": feature_issue.key }]})
Hi Trudy, thanks for the warm regards and response! The custom field type is a multi-select issue field. I tried your suggestion but received the following error:
raise TypeError(f'Object of type {o.class.name} '
TypeError: Object of type Issue is not JSON serializable
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Can you share your updated code, please?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Trudy,
Here is the updated section of code that performs the jira functions. Names of certain items were changed but functions are unchanged
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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.