Community Tip - Learn all about the Community Ranking System, a fun gamification element of the PTC Community. X
Solved! Go to Solution.
let's suppose infotable results from datatable is somwhat like id =1 and name = "rohit"
will change this name from rohit to rohit_sharma and add it back to empty infotable.
below is the snippet for this
// result: INFOTABLE dataShape: ""
// getting all infotable entries from datatable
var old_infotableresult = Things["infotableTestDT"].GetDataTableEntries({
maxItems: undefined /* NUMBER */
});
// creating an empty infotable using the datashape
var params = {
infoTableName : "InfoTable",
dataShapeName : "infotableTestDS"
};
// CreateInfoTableFromDataShape(infoTableName:STRING("InfoTable"), dataShapeName:STRING):INFOTABLE(infotableTestDS)
var result = Resources["InfoTableFunctions"].CreateInfoTableFromDataShape(params);
// looping out old infotable and updating the required row and again adding the entry to empty new infotable created
var tableLength = old_infotableresult.rows.length;
for (var x=0; x < tableLength; x++) {
var row = old_infotableresult.rows[x];
//Your code here
// infotableTestDS entry object
if(row.id == "1"){
row.name = "rohit_sharma"; // changing from rohit to rohit_sharma
}
var newEntry = new Object();
newEntry.name = row.name; // STRING
newEntry.id = row.id; // STRING [Primary Key]
result.AddRow(newEntry);
}
// in this way result infotable will be returned with updated row while other rows will be returned same as what it used to be
you can create infotable through snippets available in platform like createInfotable or create infotable from datashape or by using clone methods.
many snippets available for manipulation and creation as well under services -- > snippets -- > infotablefunctions
generally for manipulations your infotable will have datashape assigned to it. use available for loops to iterate through infotable , get values and do calculations.
to set the values to infotable, you need to create infotable entry using datashape using snippets "create infotable entry from datashape" , set values to all fields and then use AddRow(object) snippet to add the entry to infotable.
overall all snippets are available in infotablefunctions ( snippets tab on service window)
let's suppose infotable results from datatable is somwhat like id =1 and name = "rohit"
will change this name from rohit to rohit_sharma and add it back to empty infotable.
below is the snippet for this
// result: INFOTABLE dataShape: ""
// getting all infotable entries from datatable
var old_infotableresult = Things["infotableTestDT"].GetDataTableEntries({
maxItems: undefined /* NUMBER */
});
// creating an empty infotable using the datashape
var params = {
infoTableName : "InfoTable",
dataShapeName : "infotableTestDS"
};
// CreateInfoTableFromDataShape(infoTableName:STRING("InfoTable"), dataShapeName:STRING):INFOTABLE(infotableTestDS)
var result = Resources["InfoTableFunctions"].CreateInfoTableFromDataShape(params);
// looping out old infotable and updating the required row and again adding the entry to empty new infotable created
var tableLength = old_infotableresult.rows.length;
for (var x=0; x < tableLength; x++) {
var row = old_infotableresult.rows[x];
//Your code here
// infotableTestDS entry object
if(row.id == "1"){
row.name = "rohit_sharma"; // changing from rohit to rohit_sharma
}
var newEntry = new Object();
newEntry.name = row.name; // STRING
newEntry.id = row.id; // STRING [Primary Key]
result.AddRow(newEntry);
}
// in this way result infotable will be returned with updated row while other rows will be returned same as what it used to be