Missed Team ’24? Catch up on announcements here.

×
Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Search for projects which are missing a specific custom field

Sudhier Nannan December 11, 2023

Hi Everyone a NewBee here,

 

Maybe this is not the right group to ask this question in so please enlighten me if this is the case where to drop this type of questions.

I'm more a database/query kind of guy but unfortunately the policy here is to use REST API. So my question is. 

Is there a way to retrieve all projects which are missing a specific custom field in a specific Issue Type via REST API? preferably via chaining REST API calls instead of having to run different calls for each project separately.

Thank you for you help.

Gr,
Sudhier

2 answers

1 accepted

Suggest an answer

Log in or Sign up to answer
0 votes
Answer accepted
Steve Letch December 11, 2023

If you're a DB guy it'll be easier to do it via the DB I imagine.

 

Just join up some of the custom field, field context and project tables, Pull the list of all the correct ones, then tell it to spit out all the projects that aren't in the first list.

 

Although, doesn't that just mean you should be setting the field context to global? Sometimes can be easier than continually updating a context.

Sudhier Nannan December 11, 2023

Hi Steve,

True unfortunately the policy is not to just query or modify the database directly (which is also recommended by Atlassian) and use REST API instead. So here they follow these guidelines along side the fact that REST API calls are logged and therefor auditable.

I'll look in to setting the field context to global. Not yet familiar with this but if it will solve my question, why not. Thank you for your help.

Steve Letch December 11, 2023

Ah right yeh I was more talking about the identifying of which projects you need to do it for via the front end, I will say that given on occasion Atlassian's guidance in support calls and also in some of their docs is to make a db modification, it's not always off the table. Although for something so foundational as field related changes I'd air on the safe side

Like Sudhier Nannan likes this
1 vote
Alex Gerasimov
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
December 12, 2023

Hi Sudhier Nannan,

Thanks for your question. One way to fetch all projects with missing custom fields in a specific issue type over Jira REST API is to query these issues in JSON format using JQL. After that, you could parse out the project details of interest from the JSON. Please note that this approach only allows querying issues and projects you have access to.

Example:

  • Send a GET request to rest/api/2/search?jql=(cf[CUSTOM_FIELD_ID] is null AND type = ISSUE_TYPE_ID) where CUSTOM_FIELD_ID and ISSUE_TYPE_ID are integer values representing the field ID and issue type ID respectively.
  • The response might look like this (most of the fields are omitted for brevity):
{
  "expand": "schema,names",
  "startAt": 0,
  "maxResults": 50,
  "total": 50,
  "issues": [
    {
      "id": "12345",
      "key": "PROJECTKEY-1",
      "fields": {
        "customfield_CUSTOM_FIELD_ID": null,
"issuetype": { "id": "ISSUE_TYPE_ID", ... }, "project": { "self": "https://yourjiradomain.com/rest/api/2/project/67890", "id": "67890", "key": "PROJECTKEY", "name": "This is one of the projects we are looking for", "projectTypeKey": "software", ... }, ... } }, ... ] }
  • Process the response using your favorite tool to extract the project field from the issues array. You might need to de-duplicate the results as there are potentially multiple issues in each project in the response.

Hopefully, this answers your question!

Regards,

Alex

TAGS
AUG Leaders

Atlassian Community Events