Add row in DataTable
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
Add row in DataTable
Hi All,
I am creating a service that add row into a DataTable.
The problem is..I dont know my fields name.
So what I need is to iterate through the fields and add the values I want.
Something like...
for(each field){
myDataTable.field.value = value[x];
x++;
}
But in "Thingworx language".
Any tips?
Thanks!
Solved! Go to Solution.
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
I found what I wanted...that's what I am talking about!
https://community.ptc.com/t5/ThingWorx-Developers/To-generate-dynamic-values-infotable-while-inserting-updating/m-p/530617
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
I think this could help, you should be able to iterate through the Fields I think and get the names of the Fields.
---------------------------
// GetPropertyValues(): returns an INFOTABLE
var values = me.GetPropertyValues();var field;
// Now we can iterate through the INFOTABLE FIELDS through the DataShape
for each(field in values.dataShape.fields) {
var propValue = values[field.name];
if(field.baseType == "NUMBER") logger.warn(field.name + " " + field.baseType + " " + propValue);
}
- field.aspects(isPersistent)
- field.aspects(minimumValue)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
The function getProperty returns only generic fields of my datatable, but nothing about datashape.
var values = me.CreateValues();
values.a= undefined; //STRING
values.b= undefined;
What I want is: get my datashape fields and insert values...without using the code above but iterating.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
If you know which Property is your InfoTable then you can just iterate to get the fields.
for each (var field in infotable.fields)
I have some actual example lying around somewhere I could dig up, but this should work.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
I found what I wanted...that's what I am talking about!
https://community.ptc.com/t5/ThingWorx-Developers/To-generate-dynamic-values-infotable-while-inserting-updating/m-p/530617
