Community Tip - Visit the PTCooler (the community lounge) to get to know your fellow community members and check out some of Dale's Friday Humor posts! X
I have a datashape with some fields in it, then I have a "if" condition where I add two more fields to my table but when I add the values using AddRow to those two fields, they won't work.
Here's the code for more details:
var template = Things[entityName].thingTemplate;
var params = {
infoTableName : "InfoTable",
dataShapeName : "GeneralPropertiesTableShape"
};
var propertiesTable = Resources["InfoTableFunctions"].CreateInfoTableFromDataShape(params);
propertiesTable.AddRow({
label: Things[entityName].label,
strain: Things[entityName].strain,
tiltX: Things[entityName].tiltX,
tiltY: Things[entityName].tiltY,
tiltZ: Things[entityName].tiltZ,
temperature: Things[entityName].temperature,
seismic: Things[entityName].seismic
});
switch(template){
case('PointThingTemplate'):
propertiesTable.AddField({name:"substrate", baseType:"STRING"});
propertiesTable.AddRow({substrate: Things[entityName].substrate});
break;
}
my result is I can see the new field "substrate" but I see it empty
Solved! Go to Solution.
Hey Fabio,
Which version of TWX is this on? I ran your sample snippet and got the expected results:
If you want them to be on the same row, you would have to modify your code slightly to create a row object, add the additional field in the if statement, and add the row at the bottom. Note that this field wont be visible in the mashup builder because it has no way to know that this field is there in design time.
Thanks,
-James
Hey Fabio,
Which version of TWX is this on? I ran your sample snippet and got the expected results:
If you want them to be on the same row, you would have to modify your code slightly to create a row object, add the additional field in the if statement, and add the row at the bottom. Note that this field wont be visible in the mashup builder because it has no way to know that this field is there in design time.
Thanks,
-James
Ok, perfect.
I was only showing one row, that's why I saw it empty.
Problem solved.
Thank you
I modified your snippet slightly so that it will all be on one row:
var template = Things[entityName].thingTemplate;
var params = {
infoTableName : "InfoTable",
dataShapeName : "GeneralPropertiesTableShape"
};
var propertiesTable = Resources["InfoTableFunctions"].CreateInfoTableFromDataShape(params);
var row = {
label: Things[entityName].label,
strain: Things[entityName].strain,
tiltX: Things[entityName].tiltX,
tiltY: Things[entityName].tiltY,
tiltZ: Things[entityName].tiltZ,
temperature: Things[entityName].temperature,
seismic: Things[entityName].seismic
}
switch(template){
case('PointThingTemplate'):
propertiesTable.AddField({name:"substrate", baseType:"STRING"});
row.substrate = Things[entityName].substrate;
break;
}
propertiesTable.AddRow(row);
result = propertiesTable