Using a dynamic property value in bound property reference

I have many containers with some dynamic properties. For instance, strTank is the tank number/name and not bound to anything, intAge is the number of days old the product in the tank is.

Currently intAge is bound to the following expression

if(len({Root Container.cnt825.dsTankData})>0,
toInt({Root Container.cnt825.dsTankData}[0,"Age"])

When I copy this tank to several more tanks, I have to change the tank number to reflect the new number. Is there a way that I can reference this tank number in the bound expression for the intAge so I don’t have to make the same change there?

Just so you know, there are more dynamic properties for each tank, and if we copy this tank 20 times, I have to make the tank number change on 8 different properties on each tank, and the possibility of missing some is pretty good.

You shouldn’t have to change that expression when you copy the tank, unless “cnt825” is not the container you are copying. If its not, consider putting dsTankData on the tank object itself? I may be confused…

Thanks Carl, I will try that.

Along the same lines as the last question, I am trying to do this:

for tankName in tankList:
   if(event.source.parent.getComponent('cnt'+ tankName).intAge) < 14:
      edate = event.source.parent.getComponent('cnt'+ tankName).dsTankData[0,"EmptyDate"]

Basically tying to get information from the dataset that is attached to each tank, but I am getting an error and suspect that it is because of my breaking up the component name.

No, it is because you are trying to access data inside a dataset using expression-language subscripting syntax in a jython script. Take a look at the Technical Reference > Jython > Built-in Modules > fpmi.db.toPyDataSet function.

You want something more along these lines:

for tankName in tankList: tank = event.source.parent.getComponent('cnt'+ tankName) if(tank.intAge) < 14: dataset = fpmi.db.toPyDataSet(tank.dsTankData) edate = dataset[0]["EmptyDate"]

Works perfect! Thanks.