# Report - Nested Queries - Accessing variables thru scripting

**URL:** <https://forum.inductiveautomation.com/t/report-nested-queries-accessing-variables-thru-scripting/85014>\
**Category:** Ignition\
**Tags:** reporting\
**Created:** [January 31, 2024, 2:42pm UTC](https://forum.inductiveautomation.com/t/report-nested-queries-accessing-variables-thru-scripting/85014 "2024-01-31T14:42:43Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Elling\_Aarseth](https://avatars.discourse-cdn.com/v4/letter/e/bcef8e/32.png) [@Elling\_Aarseth](https://forum.inductiveautomation.com/u/Elling_Aarseth)\
**Post date:** [January 31, 2024, 2:42pm UTC](https://forum.inductiveautomation.com/t/report-nested-queries-accessing-variables-thru-scripting/85014/1 "2024-01-31T14:42:43Z")

</div>

Hi!

We're looking into using the Report Module, but need a clarification.

We are using nested Queries to structure some data. In addition to that we want to create a custom script that accesses some of the information from the nested query and adds parameters to the nested query result.

This is how the nested query is organized:

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/2/5/2516e95c8d0f783530e2cea2fae244513eef9689.png)

Spesific question:

1. How do we access the "start\_time" in the "Site"
2. How can we add a dataset to the "Site"

Thanks for all help 🙂

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [January 31, 2024, 2:56pm UTC](https://forum.inductiveautomation.com/t/report-nested-queries-accessing-variables-thru-scripting/85014/2 "2024-01-31T14:56:40Z")

</div>

See this (old) topic:

> [@Report with Scripted Nested Data](https://forum.inductiveautomation.com/t/report-with-scripted-nested-data/11801):
>
> The report datasource scripting examples explain how to access the nested data in another key for use constructing a custom dataset. What I don’t see is how to construct nested data that would be suitable for use with a child table in a table group. I have a parent dataset that I’m constructing via script due to annoying limitations of an ancient SQL Server 2000 instance. I need a subquery for each row that could be done with a normal query, but there’s no way to add a regular subquery to a s…

---

<div class="post-metadata">

**Author:** ![Elling\_Aarseth](https://avatars.discourse-cdn.com/v4/letter/e/bcef8e/32.png) [@Elling\_Aarseth](https://forum.inductiveautomation.com/u/Elling_Aarseth)\
**Post date:** [January 31, 2024, 3:11pm UTC](https://forum.inductiveautomation.com/t/report-nested-queries-accessing-variables-thru-scripting/85014/3 "2024-01-31T15:11:54Z")

</div>

Hey, and thanks for your very quick reply!

i have already looked through this thread a couple of times.  
Have tried the "addNestedQueryResults", and it seems to work great.

But i still haven't found an answer on how to access "start-time" from the "site" level in the nested query structure. in a script. Do you have a good tip on how to solve that?

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [January 31, 2024, 3:30pm UTC](https://forum.inductiveautomation.com/t/report-nested-queries-accessing-variables-thru-scripting/85014/4 "2024-01-31T15:30:38Z")

</div>

`data['trip']` is the outer `QueryResult`. Use [.getCoreResults()](https://files.inductiveautomation.com/sdk/javadoc/ignition81/8.1.30/com/inductiveautomation/reporting/common/api/QueryResults.html#getCoreResults()) on that to get its `Dataset`, and the rows thereof.
