# Access dataset of a template

**URL:** <https://forum.inductiveautomation.com/t/access-dataset-of-a-template/17915>\
**Category:** Ignition\
**Tags:** ignition79\
**Created:** [May 3, 2018, 5:36pm UTC](https://forum.inductiveautomation.com/t/access-dataset-of-a-template/17915 "2018-05-03T17:36:07Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Stuart](https://avatars.discourse-cdn.com/v4/letter/s/cab0a1/32.png) [@Stuart](https://forum.inductiveautomation.com/u/Stuart)\
**Post date:** [May 3, 2018, 5:36pm UTC](https://forum.inductiveautomation.com/t/access-dataset-of-a-template/17915/1 "2018-05-03T17:36:07Z")

</div>

I have a table that is part of a template, and I would like to be able to access the table dataset from windows where the template is used. Is this possible?

I thought about creating a custom property on the template and binding that to the table dataset, but because I already have the table dataset tied to a SQL query, this won’t work.

If the table was placed directly on the window, then I would use this: `event.source.parent.getComponent('PartsTable 1').data` to get the data attribute, but becuase it’s inside of a template, this is not possible.

Other thoughts?

---

<div class="post-metadata">

**Author:** ![brandon1](https://avatars.discourse-cdn.com/v4/letter/b/ea666f/32.png) [@brandon1](https://forum.inductiveautomation.com/u/brandon1)\
**Post date:** [May 3, 2018, 6:10pm UTC](https://forum.inductiveautomation.com/t/access-dataset-of-a-template/17915/2 "2018-05-03T18:10:18Z")

</div>

This is probably not the best solution, but you could write a [propertyChange](https://docs.inductiveautomation.com/display/DOC79/Component+Events) script on the template that copies any data that is in your table component to a template parameter each time data inside the template changes.

---

<div class="post-metadata">

**Author:** ![jpark](https://avatars.discourse-cdn.com/v4/letter/j/a88e57/32.png) [@jpark](https://forum.inductiveautomation.com/u/jpark)\
**Post date:** [May 3, 2018, 6:22pm UTC](https://forum.inductiveautomation.com/t/access-dataset-of-a-template/17915/3 "2018-05-03T18:22:16Z")

</div>

```auto
# Template
template = event.source.parent.getComponent('MyTableTemplate')

# Get the loaded template
loadedTemplate = template.loadedTemplate

# Get the table from the loaded template
myTable = loadedTemplate.getComponent("Power Table")
data = myTable.data

```

---

<div class="post-metadata">

**Author:** ![Stuart](https://avatars.discourse-cdn.com/v4/letter/s/cab0a1/32.png) [@Stuart](https://forum.inductiveautomation.com/u/Stuart)\
**Post date:** [May 3, 2018, 6:39pm UTC](https://forum.inductiveautomation.com/t/access-dataset-of-a-template/17915/4 "2018-05-03T18:39:54Z")

</div>

Cool! Thanks. Nice and easy.

Does `.loadedTemplate` get the template instance that is being used on the current page?
