2 Replies Latest reply on May 22, 2014 5:01 PM by michaelfr RSS
    michaelfr Creator

    Dynamic Thing Properties Reference


    I am trying to setup a loop that will cycle through a thing's properties based off a number and then add those values to an infotable. I don't know how to incorporate the variable number into the reference to the thing's properties though. See below code.

    var params = {

    infoTableName : "InfoTable",

    dataShapeName : "TC1_LBCSS_Soak_Tank_Information"


    var tempresult = Resources["InfoTableFunctions"].CreateInfoTableFromDataShape(params);

    for (var i = 1; i <=14; i++){



        Soak_Tank: i,

        Status: me.LB1_Soak_Tank_& i &_Status,

        Condition: me.LB1_Soak_Tank_& i &_Process_Status,

        Soak_Time: me.LB1_Soak_Tank_& i &_Soak_Time,



        var result= tempresult

    When doing it this way I receive an error. What is the correct way to incorporate the number reference inside the reference to the Thing's properties?

      • Dynamic Thing Properties Reference
        paic Collaborator

        Hi Michael, how have you been?


        JavaScript does it a little different.

        I would do it as follows:

        me["LB1_Soak_Tank_" + i + "_Process_Status"]

        A cleaner way would be to create the strings before you use it so:

        var tmpProcStat = "LB1_Soak_Tank_" + i + "_Process_Status"


        • Dynamic Thing Properties Reference
          michaelfr Creator



          I've been great, busy making wonderful tools with Thingworx! Thanks for the help with the code, this did the trick. I knew how to do it in VBA just wasn't sure with Javascript. Hopefully your workload will get a little easier with the release of 5.0!