Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Is there a way to use JQL to filter based on nested field conditions within REST?

Brandon Wright
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
January 21, 2022

Let's say I have a custom field cf[X].  That field contains another field (or object or whatever) called requestType which then contains another field serviceDeskId. 

 

"customfield_X" : {

     "requestType" : {

            "serviceDeskId" = "777"

     }

}

 

Is there a way to filter on the serviceDeskId using JQL?  Something in the vein of

cf[X].requestType.serviceDeskId=777

?

Seems this was not possible in 2015 (only nested fields question I found) but I'm hoping the basic functionality was added - though I admit no luck in finding a solution.

 

1 answer

1 accepted

2 votes
Answer accepted
Andy Heinzer
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
January 24, 2022

Hi Brandon,

If I understand correctly, you are looking into the requesttype field of a json response and want to be able to filter issues in Jira based on the serviceDeskId value of that request type.  This is not possible to do directly via JQL, either in the web UI nor in the REST API.

But that said, you could take that serviceDeskId value, and first call the endpoint of GET /rest/servicedeskapi/servicedesk/{serviceDeskId}.  This endpoint will return to you the projectId in question, such as this example:

{
"id":"2",
"projectId":"10004",
"projectName":"AJSD",
"projectKey":"AJSD",
"_links":{
"self":"https://[myCloudSite].atlassian.net/rest/servicedeskapi/servicedesk/2"
}

You can then call the search endpoint and search by the projectId, projectName, or projectKey in order to find which issues in Jira are in that project in question.

Is this a helpful alternative?  Or am I perhaps misunderstanding the endgoal here?

Let me know.

Andy

Brandon Wright
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
January 24, 2022

Hey Andy,

 

Thanks for the reply!  That was just an example of something I was looking at when I wrote the question to illustrate the idea not necessarily a specific use case.  So filtering on sub-fields is not possible directly from REST then?  I assume if you can't then it's highly unlikely that you can request sub-fields specifically in a REST query (something like fields=cf[X].SUB_FIELD_A.SUB_FIELD_B) - or is that possible?

 

Cheers

Andy Heinzer
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
January 25, 2022

The structure of the json payload you see from a REST call can show custom fields and their sub-values.  But to perform a search in Jira, it relies upon JQL.  JQL will index values for specific custom field, and in turn these can be searched for.

However the way you're describing this, I don't think you are going to be able search for issues in your way.   Jira can have lots of different custom field types, some of these might show nested values such as dependent dropdown fields or cascading select field types.

These can be searched for via JQL.  I also have a fear that the Request types field might have been a misleading example to start with, because that data is part of a system field for JSM, and technically not a user created custom field.

To see if I can better explain this, I created a dependent dropdown field in a team managed project, like so:

 Screen Shot 2022-01-25 at 11.06.14 AM.png

And then I assigned one issue a value1 of Goodbye, and value2 of forever.  From that point, instead of trying to look for a search such as dropdown=Goodbye.forever as I think you are purposing, in JQL you can just use a query of

dropdown=forever

and it will return that issue in the results.

Screen Shot 2022-01-25 at 11.05.41 AM.png

I understand this is in the web interface, but since JQL behaves in the same way in the web as the REST API, you can use this same kind of query to find the data I think you are looking for here in most custom field cases.

In turn you can then make a REST call to the search endpoint

GET /rest/api/3/search?jql=dropdown=forever

And that can return to you all the issue in Jira with that field value that your account has access to view/browse.

 I hope that helps.

Andy

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
PREMIUM
TAGS
AUG Leaders

Atlassian Community Events