cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - Did you know you can set a signature that will be added to all your posts? Set it here! X

How to get data from an infotable and separate them into properties

AV_11504623
2-Explorer

How to get data from an infotable and separate them into properties

Hello, 
I am using ThingWorx 9.3.9.
I was wondering if there was a method to get data from a infotable, and separate each of the columns in an property. In my case, I have three columns, id, temperature, and force, and I want to separate these into three different properties in a Thing. 

I have written a service in a Thing that has 4 properties, 3 of which are numbers and the last one being an infotable. 
This is my service code that I tried to use to pull one row of information from the infotable:

 

let infoTable = me.MyCSVProperty;
let searchCriteria = { 
	"id" : 2
};

let foundRow = infoTable.Find(searchCriteria);

if (foundRow!== null) {
  let id = foundRow.getValue(0);
  if (id!== null && id!== undefined) {
    me.id = id;
  } else {
    me.id = -1; // Set to -1 to indicate an error
  }
} else {
	me.id = 4;
}

 

and when i run this program i get an error:

AV_11504623_0-1721943807498.png

Any help would be greatly appreciated!
Additionally, I am new to coding and thingworx so detailed explanations would be great!

Thanks 

ACCEPTED SOLUTION

Accepted Solutions

Hi @AV_11504623 

 

Please use below code to update first row values.

 

 

let infoTable = me.MyCSVProperty;
let searchCriteria =  {
id = 2;
}
let foundRow = infoTable.Find(searchCriteria);
if(foundRow !== null)
{
// Update property values
me.id = foundRow.id;
me.thermocouple = foundRow.thermocouple;
me.force= foundRow.force;
}

 

/VR

 

View solution in original post

2 REPLIES 2

Hi @AV_11504623 

 

Please use below code to update first row values.

 

 

let infoTable = me.MyCSVProperty;
let searchCriteria =  {
id = 2;
}
let foundRow = infoTable.Find(searchCriteria);
if(foundRow !== null)
{
// Update property values
me.id = foundRow.id;
me.thermocouple = foundRow.thermocouple;
me.force= foundRow.force;
}

 

/VR

 

AV_10763160
4-Participant
(To:Velkumar)

It worked! Thank you so much!

Announcements


Top Tags