# Referring to values in code

**URL:** <https://forum.inductiveautomation.com/t/referring-to-values-in-code/113>\
**Category:** Archived Topics\
**Created:** [September 27, 2006, 9:42pm UTC](https://forum.inductiveautomation.com/t/referring-to-values-in-code/113 "2006-09-27T21:42:04Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![David](https://avatars.discourse-cdn.com/v4/letter/d/aeb1de/32.png) [@David](https://forum.inductiveautomation.com/u/David)\
**Post date:** [September 27, 2006, 9:42pm UTC](https://forum.inductiveautomation.com/t/referring-to-values-in-code/113/1 "2006-09-27T21:42:04Z")

</div>

Hi Carl:

I am attempting to modify the history graph goodie. Can you see why the following first line of code works, but not the next?

As a background, I have a container cntDatasets on the root container, on which is a label lblTank. On cntDatasets I have several datasets, one of which is a string called strTank. I can reference the text value of the label, but I cannot seem to assign a value to the dataset strTank to a value.

Tank = event.source.parent.getComponent(“cntDatasets”).getComponent(“lblTank”).text  
print Tank -----THIS ONE IS OK  
root.getComponent(“cntDatasets”).setPropertyValue(“strTank”, Tank)  
strTank = event.source.parent.getComponent(“cntDatasets”).strTank  
print strTank -----THIS ONE DOES NOT WORK.

TIA D. Lewis

---

<div class="post-metadata">

**Author:** ![Colby.Clegg](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/colby.clegg/32/3282_2.png) [@Colby.Clegg](https://forum.inductiveautomation.com/u/Colby.Clegg)\
**Post date:** [September 27, 2006, 10:16pm UTC](https://forum.inductiveautomation.com/t/referring-to-values-in-code/113/2 "2006-09-27T22:16:59Z")

</div>

Hey David, hope you don’t mind me jumping in here…

Looks like the problem is probably the fact that you can’t refer to custom properties by just saying “.name” such as where you have:  
…getComponent(“cntDatasets”).strTank

Instead, you must use “getPropertyValue”. So try changing that line to:

```auto
strTank = event.source.parent.getComponent("cntDatasets").getPropertyValue("strTank")
```

Also, “root” isn’t a valid way of getting to the root container, but I figured you probably have that defined above or something.

Hope that helps,

---

<div class="post-metadata">

**Author:** ![David](https://avatars.discourse-cdn.com/v4/letter/d/aeb1de/32.png) [@David](https://forum.inductiveautomation.com/u/David)\
**Post date:** [September 27, 2006, 10:21pm UTC](https://forum.inductiveautomation.com/t/referring-to-values-in-code/113/3 "2006-09-27T22:21:37Z")

</div>

Colby: Hey, whoever can take the time to wade through my code, thanks!

That line worked, thanks. I am sure I’ll be back with more.
