<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Count Number of Features in a feature service in ArcGIS Survey123 Questions</title>
    <link>https://community.esri.com/t5/arcgis-survey123-questions/count-number-of-features-in-a-feature-service/m-p/1134796#M39823</link>
    <description>&lt;P&gt;Hi, I posed a getCount custom JS function here: &lt;A href="https://github.com/IsmaelInRedlands/Survey123-Tricks-of-the-Trade/tree/main" target="_blank" rel="noopener"&gt;https://github.com/IsmaelInRedlands/Survey123-Tricks-of-the-Trade/tree/main&lt;/A&gt;&lt;/P&gt;&lt;P&gt;This is what it looks like:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;function getCount(featureLayer,token){
   
	var xmlhttp = new XMLHttpRequest();
	var url = featureLayer + "/query?f=json&amp;amp;where=1=1&amp;amp;returnCountOnly=true";

	if (token){
        url = url + "&amp;amp;token=" + token;
    }

	xmlhttp.open("GET",url,false);
	xmlhttp.send();

	if (xmlhttp.status!==200){
         return (xmlhttp.status);
    } else {
	var responseJSON=JSON.parse(xmlhttp.responseText)
	if (responseJSON.error){
         return (JSON.stringify(responseJSON.error));
       } else {
      	 return JSON.stringify(responseJSON.count);
       }
    }
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;For the feature layer parameter, pass the URL including the layer index. For example:&lt;/P&gt;&lt;BLOCKQUOTE&gt;&lt;P&gt;&lt;A href="https://services2.arcgis.com/fJJEXNgxjn0dpNsi/ArcGIS/rest/services/Carriage_Trail/FeatureServer/0" target="_blank" rel="noopener"&gt;https://services2.arcgis.com/fJJEXNgxjn0dpNsi/ArcGIS/rest/services/Carriage_Trail/FeatureServer/0&lt;/A&gt;&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;If your layer is shared publicly, you do not need to pass the second parameter. To get the token from the user, use:&lt;/P&gt;&lt;BLOCKQUOTE&gt;&lt;P&gt;pulldata("@property","token")&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;Starting with the 3.16 release, you can also make use of the pulldata("@layer") function. Check:&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;&lt;A href="https://community.esri.com/t5/arcgis-survey123-blog/survey123-tricks-of-the-trade-pulldata-quot-layer/ba-p/1224415" target="_blank" rel="noopener"&gt;https://community.esri.com/t5/arcgis-survey123-blog/survey123-tricks-of-the-trade-pulldata-quot-laye...&lt;/A&gt;&amp;nbsp;&lt;/LI&gt;&lt;LI&gt;&lt;A href="https://community.esri.com/t5/arcgis-survey123-videos/survey123-tricks-of-the-trade-live-query-arcgis/m-p/1228072#M54" target="_blank"&gt;https://community.esri.com/t5/arcgis-survey123-videos/survey123-tricks-of-the-trade-live-query-arcgis/m-p/1228072#M54&lt;/A&gt;&amp;nbsp;&lt;/LI&gt;&lt;/UL&gt;</description>
    <pubDate>Fri, 04 Nov 2022 20:59:37 GMT</pubDate>
    <dc:creator>IsmaelChivite</dc:creator>
    <dc:date>2022-11-04T20:59:37Z</dc:date>
    <item>
      <title>Count Number of Features in a feature service</title>
      <link>https://community.esri.com/t5/arcgis-survey123-questions/count-number-of-features-in-a-feature-service/m-p/1133931#M39776</link>
      <description>&lt;P&gt;Hello -&lt;/P&gt;&lt;P&gt;I'm trying to generate a unique number for each survey submittal (e.g. 2022-001) and was going to try to use the count of features that were already in the service. My thought is that I would use a custom JS/pull data to query the feature service and count the number of records when the survey is started. Does anyone have an example of how that would look for someone who is very very rough at javascript? I'm attaching what I have right now, which I know is definitely not right.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="RosemaryHatch_0-1642178177539.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/31543i021378B2F5E7F7EE/image-size/medium?v=v2&amp;amp;px=400" role="button" title="RosemaryHatch_0-1642178177539.png" alt="RosemaryHatch_0-1642178177539.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Thank you!&lt;/P&gt;</description>
      <pubDate>Fri, 14 Jan 2022 16:37:08 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-survey123-questions/count-number-of-features-in-a-feature-service/m-p/1133931#M39776</guid>
      <dc:creator>RosemaryHatch</dc:creator>
      <dc:date>2022-01-14T16:37:08Z</dc:date>
    </item>
    <item>
      <title>Re: Count Number of Features in a feature service</title>
      <link>https://community.esri.com/t5/arcgis-survey123-questions/count-number-of-features-in-a-feature-service/m-p/1134796#M39823</link>
      <description>&lt;P&gt;Hi, I posed a getCount custom JS function here: &lt;A href="https://github.com/IsmaelInRedlands/Survey123-Tricks-of-the-Trade/tree/main" target="_blank" rel="noopener"&gt;https://github.com/IsmaelInRedlands/Survey123-Tricks-of-the-Trade/tree/main&lt;/A&gt;&lt;/P&gt;&lt;P&gt;This is what it looks like:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;function getCount(featureLayer,token){
   
	var xmlhttp = new XMLHttpRequest();
	var url = featureLayer + "/query?f=json&amp;amp;where=1=1&amp;amp;returnCountOnly=true";

	if (token){
        url = url + "&amp;amp;token=" + token;
    }

	xmlhttp.open("GET",url,false);
	xmlhttp.send();

	if (xmlhttp.status!==200){
         return (xmlhttp.status);
    } else {
	var responseJSON=JSON.parse(xmlhttp.responseText)
	if (responseJSON.error){
         return (JSON.stringify(responseJSON.error));
       } else {
      	 return JSON.stringify(responseJSON.count);
       }
    }
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;For the feature layer parameter, pass the URL including the layer index. For example:&lt;/P&gt;&lt;BLOCKQUOTE&gt;&lt;P&gt;&lt;A href="https://services2.arcgis.com/fJJEXNgxjn0dpNsi/ArcGIS/rest/services/Carriage_Trail/FeatureServer/0" target="_blank" rel="noopener"&gt;https://services2.arcgis.com/fJJEXNgxjn0dpNsi/ArcGIS/rest/services/Carriage_Trail/FeatureServer/0&lt;/A&gt;&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;If your layer is shared publicly, you do not need to pass the second parameter. To get the token from the user, use:&lt;/P&gt;&lt;BLOCKQUOTE&gt;&lt;P&gt;pulldata("@property","token")&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;Starting with the 3.16 release, you can also make use of the pulldata("@layer") function. Check:&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;&lt;A href="https://community.esri.com/t5/arcgis-survey123-blog/survey123-tricks-of-the-trade-pulldata-quot-layer/ba-p/1224415" target="_blank" rel="noopener"&gt;https://community.esri.com/t5/arcgis-survey123-blog/survey123-tricks-of-the-trade-pulldata-quot-laye...&lt;/A&gt;&amp;nbsp;&lt;/LI&gt;&lt;LI&gt;&lt;A href="https://community.esri.com/t5/arcgis-survey123-videos/survey123-tricks-of-the-trade-live-query-arcgis/m-p/1228072#M54" target="_blank"&gt;https://community.esri.com/t5/arcgis-survey123-videos/survey123-tricks-of-the-trade-live-query-arcgis/m-p/1228072#M54&lt;/A&gt;&amp;nbsp;&lt;/LI&gt;&lt;/UL&gt;</description>
      <pubDate>Fri, 04 Nov 2022 20:59:37 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-survey123-questions/count-number-of-features-in-a-feature-service/m-p/1134796#M39823</guid>
      <dc:creator>IsmaelChivite</dc:creator>
      <dc:date>2022-11-04T20:59:37Z</dc:date>
    </item>
    <item>
      <title>Re: Count Number of Features in a feature service</title>
      <link>https://community.esri.com/t5/arcgis-survey123-questions/count-number-of-features-in-a-feature-service/m-p/1134799#M39824</link>
      <description>&lt;P&gt;This is perfect, thank you!!&lt;/P&gt;</description>
      <pubDate>Tue, 18 Jan 2022 21:49:11 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-survey123-questions/count-number-of-features-in-a-feature-service/m-p/1134799#M39824</guid>
      <dc:creator>RosemaryHatch</dc:creator>
      <dc:date>2022-01-18T21:49:11Z</dc:date>
    </item>
    <item>
      <title>Re: Count Number of Features in a feature service</title>
      <link>https://community.esri.com/t5/arcgis-survey123-questions/count-number-of-features-in-a-feature-service/m-p/1228901#M45888</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/2929"&gt;@IsmaelChivite&lt;/a&gt;,&lt;/P&gt;&lt;P&gt;I am able to return a count of all the records, can I return the count of a variable in the attribute table? Like Count how many records are "Apple" or "Orange"?&lt;/P&gt;&lt;P&gt;Jerry&lt;/P&gt;</description>
      <pubDate>Fri, 04 Nov 2022 20:55:01 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-survey123-questions/count-number-of-features-in-a-feature-service/m-p/1228901#M45888</guid>
      <dc:creator>JerrySneary</dc:creator>
      <dc:date>2022-11-04T20:55:01Z</dc:date>
    </item>
    <item>
      <title>Re: Count Number of Features in a feature service</title>
      <link>https://community.esri.com/t5/arcgis-survey123-questions/count-number-of-features-in-a-feature-service/m-p/1228911#M45889</link>
      <description>&lt;P&gt;Replace the WHERE statement in the URL as shown below for fruit='apple'&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;var url = featureLayer + "/query?f=json&amp;amp;where=fruit='apple'&amp;amp;returnCountOnly=true";&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Starting with the 3.16 release, you can also make use of the pulldata("@layer") function. Check:&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;&lt;A href="https://community.esri.com/t5/arcgis-survey123-blog/survey123-tricks-of-the-trade-pulldata-quot-layer/ba-p/1224415" target="_blank" rel="noopener"&gt;https://community.esri.com/t5/arcgis-survey123-blog/survey123-tricks-of-the-trade-pulldata-quot-layer/ba-p/1224415&lt;/A&gt;&amp;nbsp;&lt;/LI&gt;&lt;LI&gt;&lt;A href="https://community.esri.com/t5/arcgis-survey123-videos/survey123-tricks-of-the-trade-live-query-arcgis/m-p/1228072#M54" target="_blank"&gt;https://community.esri.com/t5/arcgis-survey123-videos/survey123-tricks-of-the-trade-live-query-arcgis/m-p/1228072#M54&lt;/A&gt;&amp;nbsp;&lt;/LI&gt;&lt;/UL&gt;</description>
      <pubDate>Fri, 04 Nov 2022 20:59:54 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-survey123-questions/count-number-of-features-in-a-feature-service/m-p/1228911#M45889</guid>
      <dc:creator>IsmaelChivite</dc:creator>
      <dc:date>2022-11-04T20:59:54Z</dc:date>
    </item>
    <item>
      <title>Re: Count Number of Features in a feature service</title>
      <link>https://community.esri.com/t5/arcgis-survey123-questions/count-number-of-features-in-a-feature-service/m-p/1482250#M57180</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/2929"&gt;@IsmaelChivite&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;&lt;P&gt;Is it possible to use two fields to get a count? I'm using the syntax below but it only allows me to use one or the other not both at the same time.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="c"&gt;var url = featureLayer + "/query?f=json&amp;amp;where=fruit='apple'&amp;amp;where=color='Red'&amp;amp;returnCountOnly=true";&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Kind regards,&lt;/P&gt;&lt;P&gt;Jerry&lt;/P&gt;</description>
      <pubDate>Fri, 31 May 2024 20:17:13 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-survey123-questions/count-number-of-features-in-a-feature-service/m-p/1482250#M57180</guid>
      <dc:creator>JerrySneary</dc:creator>
      <dc:date>2024-05-31T20:17:13Z</dc:date>
    </item>
  </channel>
</rss>

