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

alternate for loop

Test_user
9-Granite

alternate for loop

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

1 ACCEPTED SOLUTION

Accepted Solutions
Ashritha
13-Aquamarine
(To:Test_user)

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!!

 

View solution in original post

3 REPLIES 3
M4RC
14-Alexandrite
(To:Test_user)

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
});

 

Ashritha
13-Aquamarine
(To:Test_user)

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!!

 

jensc
17-Peridot
(To:Test_user)

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

 

Top Tags