cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - You can subscribe to a forum, label or individual post and receive email notifications when someone posts a new topic or reply. Learn more! X

Using infotable

VaibhavShinde
16-Pearl

Using infotable

Hi ,
I want to know how many ways we can create infotable and which one is preferable. And how to manipulate infotable data in other things and use its field value.

Thank you
1 ACCEPTED SOLUTION

Accepted Solutions

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 

 

View solution in original post

3 REPLIES 3

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)

Hello rosharma,
Thank you for your reply but
Suppose i have to update or add a name field value whose id is 1. Then how it should be done in jnfotable.
Please reply for this
Thank you

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 

 

Top Tags