Search code examples
pythoncheckboxjirajira-rest-apipython-jira

How to set multi check box in jira using python


I actually want to enable First time Resolution check box via python which is displayed in the Resolved workflow in a separate window I could fetch the feild Id. I have tried many ways but couldn't succeed.(Python)

here are few ways I have tried:

  1. issue.fields.customfield_10112 = [{"value": "Resolved First Time"}] or [{"value": "Yes"}]

The above hasn't worked.

  1. fields = {"customfield_10112": [{"value": "Resolved First Time"}]} issue.update(fields=fields)

the above method I have tried throws an error-text: Field 'customfield_10112' cannot be set. It is not on the appropriate screen, or unknown.

I am attaching a screenshot of which checkbox should be enabled.

enter image description here

I would request anyone to help me on this.


Solution

  • With the Python code, you're editing the issue. But your screenshot comes from the Resolved transition.

    When you edit an issue, only fields available on the 'Edit screen' can be updated (incl. REST API methods). The field First Time Resolution (customfield_10112) is most probably not on the Edit screen, i.e. the field can be changed only through the Resolved transition (the field is on the 'transition screen').

    In other words, you have to transition the issue and pass the function the field(s) you want to change.

    issue = jira.issue('MYISSUE-1')
    fields = {
        "customfield_10112" : [{"value": "Resolved First Time"}],
        "resolution"        : { 'id': '3'}} # Resolution is mandatory on your screen
    jira.transition_issue(issue, '5', fields=fields)
    

    See this: https://jira.readthedocs.io/en/latest/examples.html#transitions