Skip to main content
10-Marble
February 10, 2023
Solved

alternate for loop

  • February 10, 2023
  • 3 replies
  • 1431 views

What can be used instead of for loop to loop through 10000 records which is present in Infotable?

Best answer by Ashritha

Hi ,

 

If you need to find row based on some column value , you can use following snippet.

let params = {
	t: undefined /* INFOTABLE */,
	query: undefined /* QUERY */
};

// result: INFOTABLE
let result = Resources["InfoTableFunctions"].Query(params);

 Query can be created as in link .

 

Hope it helps!!

 

3 replies

14-Alexandrite
February 10, 2023

Hello,

 

I don't know your context, however you may be able to reduce the number of calls by including the ".Array.prototype.filter()" parameter to one/both of your loops.

 

infoTableName.rows.toArray().filter(singleRow => singleRow.field == true).forEach(singleRow => {
 //do magic
});

 

Ashritha15-MoonstoneAnswer
15-Moonstone
February 10, 2023

Hi ,

 

If you need to find row based on some column value , you can use following snippet.

let params = {
	t: undefined /* INFOTABLE */,
	query: undefined /* QUERY */
};

// result: INFOTABLE
let result = Resources["InfoTableFunctions"].Query(params);

 Query can be created as in link .

 

Hope it helps!!

 

17-Peridot
February 10, 2023

Hello,

 

I think previous answers provide the information that you wanted.

But I wanted to post this here as well if it might help decide on the best way of looping: Tips-and-Tricks-for-ThingWorx-Developers-Dependencies-JavaScript 

 

#2 in this link will provide some information regarding the different loop options you have.

 

Regards,

Jens