How to include Custom Fields/Forms in Subqueries?
Got feedback or spotted a mistake?

Leave a comment at the end of this page or email contact@krishagni.com

How to include Custom Fields/Forms in Subqueries?

Currently, in Queries, you will receive an error when including ‘Custom Field’, like: “Consented Status ”, attached to a participant-level custom field for the mGen collection protocol, and then use this as a sub-query to another query.

image-20250715-130627.png

It is likely, the users want to run a report, and only get details for participants/visits/specimens that have certain criteria, which is added to a custom field level.

Example: In a single report, get a count of participants who consented to the collection protocol mGen and My Healthy Maryland.

Why?

When no CP is selected, the UI has no knowledge of the custom fields. Therefore the custom fields based filters from subqueries are wiped out in the main query resulting to an error.

Workaround

  1. Add the custom field to your subquery as usual.

    image-20250715-133638.png
  2. Use this subquery in your main query as usual.

    image-20250715-141440.png
  3. Click View Records — ignore any error message. Select the columns you need and save the query.

    image-20250715-133923.png
  4. Go back to the Queries list and schedule it as a Job with Run On Demand.

    image-20250715-134316.png
    image-20250715-134441.png
  5. Go to Jobs, click Run, and you’ll get the results in a CSV file via email.

    image-20250715-134637.png
    image-20250715-134827.png
Got feedback or spotted a mistake?

Leave a comment at the end of this page or email contact@krishagni.com