Creating JQL query to retrieve test executions linked to specific test plan in Xray

I need help building a JQL search that will return all test executions associated with a particular test plan in Jira Xray. I already have the test plan key available.

I realize this might seem odd because you can view the executions directly from the test plan interface. However, I’m working on automating execution creation through the API. The issue is that when I query the test plan via API, it doesn’t show the connected executions - the relationship only works in reverse (executions reference their test plan). That’s why I want to use JQL to fetch them instead.

What would be the correct JQL syntax to accomplish this?

you might also need to check if your using the right field ID instead of field name. sometimes xray uses cf[xxxxx] format for custom felds. try going to issues → search → advanced and look at the field suggestions when you type “test plan”. also make sure your user has proper permissions to see all executions, that caught me before.

The JQL syntax you’re looking for would be something like “Test Plan” = “PROJ-123” where PROJ-123 is your actual test plan key. This should pull all test executions that reference that specific test plan. I’ve run into similar situations when working with Xray automation. The directional relationship issue you mentioned is a common pain point - the API responses don’t always include the full object graph you’d expect. Using JQL as a workaround is actually a solid approach for automation workflows. One thing to watch out for is that depending on your Xray version, the field name might vary slightly. If the above doesn’t work, try checking your field configuration or use the advanced search builder in Jira to see how the Test Plan field is actually named in your instance. Sometimes it shows up as a custom field with a different identifier.

Another approach that works reliably is using the “Test Execution” issue type filter combined with the test plan reference. Try this JQL: project = “YOUR_PROJECT” AND issuetype = “Test Execution” AND “Test Plan” ~ “PROJ-123”. The tilde operator can be helpful if you’re dealing with multiple test plans or partial matches. I’ve found this method particularly useful when dealing with bulk operations through the API since it gives you more control over the result set. Just make sure to replace YOUR_PROJECT with your actual project key. If you’re still having issues, double-check that your Jira instance has the proper Xray fields indexed for JQL searches. Sometimes administrators need to manually reindex certain custom fields before they become searchable through JQL queries.