JavaScript API 4.24 - Feature Table - Getting Records Counts from Table into Console.log?

617
3
Jump to solution
11-01-2022 02:09 PM
ipeebles
New Contributor II

Hello everyone. I have a working app that includes using a query to return results to a feature table.  The feature table shows the number of records returned and selected.

My question is, how can I return the number of records from the feature table in console.log?  I am wanting to set up some alerts for end users if the results are 0.

I thought I could dome something like results.length, but that does not seem to be available.

Any ideas?  Thank you!

Tags (1)
0 Kudos
1 Solution

Accepted Solutions
ipeebles
New Contributor II

This seems to be the solution I am looking for...

// Gets Records in Console for Feature Table
featureLayer.queryFeatureCount().then(function(numFeatures){
// prints the total count to the console
console.log("Feature Table - Number of Features Returned: ", numFeatures);
});

 

This snippet of code will return the number of features that are populated in the feature table based on the definition query from the feature layer.

 

 

View solution in original post

0 Kudos
3 Replies
JayakumarPD
Occasional Contributor

Is it possible to share the code

0 Kudos
ipeebles
New Contributor II

This seems to be the solution I am looking for...

// Gets Records in Console for Feature Table
featureLayer.queryFeatureCount().then(function(numFeatures){
// prints the total count to the console
console.log("Feature Table - Number of Features Returned: ", numFeatures);
});

 

This snippet of code will return the number of features that are populated in the feature table based on the definition query from the feature layer.

 

 

0 Kudos
JayakumarPD
Occasional Contributor

Good you got the solution !

0 Kudos