# Referencing current container

**URL:** <https://forum.inductiveautomation.com/t/referencing-current-container/4297>\
**Category:** Ignition\
**Created:** [April 16, 2012, 2:32am UTC](https://forum.inductiveautomation.com/t/referencing-current-container/4297 "2012-04-16T02:32:23Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![techerdone](https://avatars.discourse-cdn.com/v4/letter/t/9fc348/32.png) [@techerdone](https://forum.inductiveautomation.com/u/techerdone)\
**Post date:** [April 16, 2012, 2:32am UTC](https://forum.inductiveautomation.com/t/referencing-current-container/4297/1 "2012-04-16T02:32:23Z")

</div>

I am looking for a way to reference the current container so I can dynamically get some datasets from the current containers chart.

I have looked at getSibling which does exactly what I want but I am working in the script module and I don’t believe you can use this function because it requires an event object. This script runs on a time interval and is not activated by an event…

Here’s what I have ended up doing:

`	domain = system.gui.getWindow('ProjectStatus').getRootContainer().getComponent(container)
	irrTbl = domain.getComponent('Chart').Irr`  
where ‘container’ is a variable passed in to the function that is the name of the current container I want to get dataset from.

Thanks.

---

<div class="post-metadata">

**Author:** ![Travis.Cox](https://avatars.discourse-cdn.com/v4/letter/t/b9bd4f/32.png) [@Travis.Cox](https://forum.inductiveautomation.com/u/Travis.Cox)\
**Post date:** [April 16, 2012, 3:03pm UTC](https://forum.inductiveautomation.com/t/referencing-current-container/4297/2 "2012-04-16T15:03:37Z")

</div>

Why don’t you just pass in the event object to the function? You can then just do:`irrTbl = event.source.getComponent('Chart').Irr`

---

<div class="post-metadata">

**Author:** ![techerdone](https://avatars.discourse-cdn.com/v4/letter/t/9fc348/32.png) [@techerdone](https://forum.inductiveautomation.com/u/techerdone)\
**Post date:** [April 19, 2012, 12:17am UTC](https://forum.inductiveautomation.com/t/referencing-current-container/4297/3 "2012-04-19T00:17:44Z")

</div>

I guess I just don’t get how to pass an ‘event’ object to my function without doing it in an Event Handler Script. I had been trying to do what you recommended but had not luck.

How do you pass an ‘event’ object to a function from the runScript function in the expression binding?

From everything I’ve read and tried it seems the Event Handler scripting module is the only way to use the ‘event’ objects. Am I mistaken?

Thanks.

---

<div class="post-metadata">

**Author:** ![Travis.Cox](https://avatars.discourse-cdn.com/v4/letter/t/b9bd4f/32.png) [@Travis.Cox](https://forum.inductiveautomation.com/u/Travis.Cox)\
**Post date:** [April 19, 2012, 12:26am UTC](https://forum.inductiveautomation.com/t/referencing-current-container/4297/4 "2012-04-19T00:26:06Z")

</div>

Oh, I didn’t know you were doing it from a runScript. You can’t pass in the event object in the runScript since there is no event object. It only exists in Event Handlers like you said.

Unfortunately, with a run script you will have to tell the function which window and container to get the info from. I would add three arguments to your function like this:`runScript("app.pkg.function('WindowName', 'ContainerName', 'ComponentName')", 5000)`where your function will do the following:`def function(windowName, contName, compName):
    domain = system.gui.getWindow(windowName).getRootContainer().getComponent(contName)
    irrTbl = domain.getComponent(compName).Irr`That is all you can do right now.

---

<div class="post-metadata">

**Author:** ![techerdone](https://avatars.discourse-cdn.com/v4/letter/t/9fc348/32.png) [@techerdone](https://forum.inductiveautomation.com/u/techerdone)\
**Post date:** [April 19, 2012, 5:22am UTC](https://forum.inductiveautomation.com/t/referencing-current-container/4297/5 "2012-04-19T05:22:16Z")

</div>

Ok, that’s basically how I’ve got it going. Just wanted to make sure I was not missing something.

Do you think there is enough need for you guys to implement a runScript function that can except various types of objects in the argument?

Thanks again for your help, Travis.
