Community Tip - Learn all about the Community Ranking System, a fun gamification element of the PTC Community. X
I want to write a service to delete the entries of an infotable which is a property of a thing.
Solved! Go to Solution.
Priyanshi Saxena Since you already have pointed out that you are able to delete the data of info tables yourself and you are looking for PTC recommended way , I would suggest reading the below lines in the screenshot .
Hi,
There's lot's of ways to accomplish this, but you should follow some steps:
1. Clone the Infotable type property
2. Modify the cloned infotable
3. Set the Infotable property with the new cloned property.
Some code:
var copy = Resources["InfoTableFunctions"].Clone({ t1: me.infotablePropertyName });
// -- Option 1, by object
copy.Delete(yourRowValueHere);
// -- Option 2, filtering data
copy.Filter(yourRowValueHere);
// or
copy = Resource["InfoTableFunctions"].EQFilter({ t: copy, fieldName:"fieldNameToFilter", value: "value" });
// or any other Filtering options on InfoTableFunctions resource
// -- Option 3, iterating over data;
var nRows = copy.rows.length;
for (var i=0;i<nRows;i++) {
if ("rowAccompliesAConditionToDelete") {
delete copy.rows;
i--;
nRows--;
}
}
// -- And set again the property
me.infotablePropertyName = copy
I want to delete all the entries of the infotable, then what would be row value in following command
copy.Delete(yourRowValueHere);
If you want to delete all, you can create a new Infotable with the same DataShape and set the property with it.
Actually my infotable contains location object which is binded to the google map. My requirement is that after every 2 minutes the infotable should be cleared and fresh entries should be displayed on the map. Presently all the entries in the infotable are displayed since the time infotable was created.
Hi Priyanshi Saxena Even to achieve this , steps would be same as Carles Coll mentioned .
You have iterate these same steps everytime you want this to happen.
Steps to be iterated are :
1. Clone the Infotable type property
2. Modify the cloned infotable
3. Set the Infotable property with the new cloned property.
You can add one more steps to delete the property(info table ) once a new one is cloned.
Again if you want only changed values to be overridden in info table , then in that case , Option 3, iterating over data would be one you will need.
Or you can also use option 3 to delete all data by making the if condition true. (ie removing the condition )
// -- Option 3, iterating over data;
var nRows = copy.rows.length;
for (var i=0;i<nRows;i++) {
if ("rowAccompliesAConditionToDelete") {
delete copy.rows;
i--;
nRows--;
}
}
The codes given above are very helpful , however if you still need help in getting this done. Do let us know .
Carles Coll Please advise if I am wrong , your help would surely make us understand as if which would be optimal solution in requirements like this.
Thanks in Advance !
Ravi Upadhyay
I don't know if I am right but I tried using the following snippet:
me.MyInfoTable.RemoveAllRows();
and it did delete all the entries of the infotable.
I am not sure if it is the recommended way to do it.
This is what you want , deleting all the entries of the info table , if it works for you . Its Good
Priyanshi Saxena Since you already have pointed out that you are able to delete the data of info tables yourself and you are looking for PTC recommended way , I would suggest reading the below lines in the screenshot .
Hi Ravi,
Thank you so much for your help. The information was of great use.