Community Tip - Did you know you can set a signature that will be added to all your posts? Set it here! X
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:
Any help would be greatly appreciated!
Additionally, I am new to coding and thingworx so detailed explanations would be great!
Thanks
Solved! Go to Solution.
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
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
It worked! Thank you so much!