-1

I am doing automation on Jira, now I want fetch the data from tickets, but the tickets must have the customfield_10030, otherwise the tickets should not be selected.

Below is the code, I am using, please help me out

from atlassian import Jira
jira_instance = Jira(
        url = "https://xxxxxxx.atlassian.net/",
        username = "username@gmail.com",
        password = "API token",
    )
data = jira_instance.jql("project = ProjectName AND status = 'Open' ORDER BY created ASC")

The above code fetches all the tickets in open status under the project. But I want to fetch all the tickets in open status and has the customfield_10030, only then it should be selected.

Please help me out in this

Daniel Haley
  • 51,389
  • 6
  • 69
  • 95
Beginner
  • 143
  • 1
  • 12
  • 1
    Please be aware this is not a code-writing or tutoring service. We can help solve specific, technical problems, not open-ended requests for code or advice. Please edit your question to show what you have tried so far, and what specific problem you need help with. See the [How To Ask a Good Question](https://stackoverflow.com/help/how-to-ask "How To Ask a Good Question") page for details on how to best help us help you. – itprorh66 Jun 01 '21 at 15:33
  • 2
    Seems like a jql question. [Maybe this will help.](https://support.atlassian.com/jira-core-cloud/docs/advanced-search-reference-jql-fields/#Advancedsearchingfieldsreference-customCustomfield) – Daniel Haley Jun 01 '21 at 15:51
  • @itprorh66 I have done with the automation completely by fetching fields data from the tickets, once processed, the ticket will be assigned to other person, and the status will be changed. Now, I want to filter out the tickets that I am accessing based on one of the customfield. – Beginner Jun 02 '21 at 04:17
  • @itprorh66 before coming to this forum, I have found based customfield value, we can filter, the same link & solution has been shared by others here. But my concern is, I need to filter out the tickets which has that customfield, I am not talking about the value of customfield. – Beginner Jun 02 '21 at 04:20

2 Answers2

2

JQL:

customfield_10030 is not empty

mdoar
  • 6,758
  • 1
  • 21
  • 20
1

The JQL would be: project = ProjectName AND status = 'Open' AND cf[10030] is not empty ORDER BY created ASC

It's best to refer to custom fields by their ID, not their name, in case someone changes the name or there are other fields with the same name.

David Bakkers
  • 453
  • 3
  • 13
  • That is true, but makes it harder to understand the query later on. When we change a custom field name, we find all the saved filters that use it and email the filter owners. If they use their filter, they can change it. And as for allowing two fields with the same name, well, that's just a bad idea for lots of reasons :) – mdoar Jun 03 '21 at 17:14