<?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: uniqueValues function error in ArcGIS JavaScript Maps SDK Questions</title>
    <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/uniquevalues-function-error/m-p/262824#M24375</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Ohhh... after I posted the question I got the answer by re-reading the uniqueValues function documentation.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The message was clear in the first place: it was missing the view.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;There's a view parameter for the uniqueValues function that was not part of the sample code...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;DIV class="" style="color: #4c4c4c; background: linear-gradient(#efefef, #f8f8f8, #efefef, #cccccc) #ffffff; border: 1px solid #cccccc; font-weight: 300; margin-bottom: 0.625rem; padding: 0.5rem;"&gt;&lt;SPAN class="" style="font-weight: bold;"&gt;view&lt;/SPAN&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN class="" style="background-color: #f8f8f8; border: 1px solid #cccccc; margin-left: 0.3125em; padding: 4px 0px;"&gt;&lt;SPAN class="" style="padding: 0px 5px;"&gt;&lt;A href="https://developers.arcgis.com/javascript/latest/api-reference/esri-views-View.html" style="color: #0079c1; text-decoration: none;"&gt;View&lt;/A&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/DIV&gt;&lt;P&gt;&lt;SPAN class="" style="color: #4c4c4c; background-color: #efefef; border: 1px solid #cccccc; font-weight: 300; margin-bottom: 0.625rem; padding: 2px 4px;"&gt;optional&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="color: #4c4c4c; background-color: #ffffff; font-weight: 300; margin: 0.5rem 0px;"&gt;A&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;A href="https://developers.arcgis.com/javascript/latest/api-reference/esri-views-SceneView.html" style="color: #0079c1; text-decoration: none;"&gt;SceneView&lt;/A&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;or&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;A href="https://developers.arcgis.com/javascript/latest/api-reference/esri-views-MapView.html" style="color: #0079c1; text-decoration: none;"&gt;MapView&lt;/A&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;instance is required when a&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;CODE style="color: #595959; background-color: #f8f8f8; border: 1px solid #efefef; font-size: 0.875em;"&gt;valueExpression&lt;/CODE&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;is specified.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So what I had to do was this:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="background-color: #ffffff; border: 0px;"&gt;uniqueValues({&lt;BR /&gt;layer: layer,&lt;BR /&gt;field: "sStatus",&lt;/P&gt;&lt;P style="background-color: #ffffff; border: 0px;"&gt;&lt;STRONG&gt;view: mapView&lt;/STRONG&gt;&lt;BR /&gt;}).then(function (response) {&lt;BR /&gt;// prints each unique value and the count of features containing that value&lt;BR /&gt;var infos = response.uniqueValueInfos;&lt;/P&gt;&lt;P style="background-color: #ffffff; border: 0px;"&gt;console.log('test');&lt;/P&gt;&lt;P style="background-color: #ffffff; border: 0px;"&gt;infos.forEach(function (info) {&lt;BR /&gt;console.log("Wells : ", info.value, " # OF CAMPAIGN STOPS: ", info.count);&lt;BR /&gt;});&lt;BR /&gt;}).catch(errback);&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 24 Jan 2019 20:14:36 GMT</pubDate>
    <dc:creator>LenielMaccaferri</dc:creator>
    <dc:date>2019-01-24T20:14:36Z</dc:date>
    <item>
      <title>uniqueValues function error</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/uniquevalues-function-error/m-p/262823#M24374</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I'm trying to make use of uniqueValues function:&amp;nbsp;&lt;A class="link-titled" href="https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-statistics-uniqueValues.html" title="https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-statistics-uniqueValues.html"&gt;uniqueValues | API Reference | ArcGIS API for JavaScript 4.10&lt;/A&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;However, it's failing with this message:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #ff0000;"&gt;message: "view is required to query stats from layerView"&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="color: #ff0000;"&gt;name: "feature-layer-adapter:insufficient-data"&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have a FeatureLayer with features and a field called sStatus... I also have a Legend setup that is working just fine with a UniqueValueRenderer based on this sStatus field.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This is my code:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;uniqueValues({&lt;BR /&gt;layer: layer,&lt;BR /&gt;field: "sStatus"&lt;BR /&gt;}).then(function (response) {&lt;BR /&gt;// prints each unique value and the count of features containing that value&lt;BR /&gt;var infos = response.uniqueValueInfos;&lt;/P&gt;&lt;P&gt;console.log('test');&lt;/P&gt;&lt;P&gt;infos.forEach(function (info) {&lt;BR /&gt;console.log("Wells : ", info.value, " # OF CAMPAIGN STOPS: ", info.count);&lt;BR /&gt;});&lt;BR /&gt;}).catch(errback);&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Note: if I change the field name to something as "status" the error message in the Console changes:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #ff0000;"&gt;message: "Unknown fields: status. You can only use fields defined in the layer schema"&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="color: #ff0000;"&gt;name: "unique-values:invalid-parameters"&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This shows that my field sStatus is right but I don't get why it doesn't work out of the box.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Any ideas why this is failing?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 24 Jan 2019 20:04:17 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/uniquevalues-function-error/m-p/262823#M24374</guid>
      <dc:creator>LenielMaccaferri</dc:creator>
      <dc:date>2019-01-24T20:04:17Z</dc:date>
    </item>
    <item>
      <title>Re: uniqueValues function error</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/uniquevalues-function-error/m-p/262824#M24375</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Ohhh... after I posted the question I got the answer by re-reading the uniqueValues function documentation.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The message was clear in the first place: it was missing the view.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;There's a view parameter for the uniqueValues function that was not part of the sample code...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;DIV class="" style="color: #4c4c4c; background: linear-gradient(#efefef, #f8f8f8, #efefef, #cccccc) #ffffff; border: 1px solid #cccccc; font-weight: 300; margin-bottom: 0.625rem; padding: 0.5rem;"&gt;&lt;SPAN class="" style="font-weight: bold;"&gt;view&lt;/SPAN&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN class="" style="background-color: #f8f8f8; border: 1px solid #cccccc; margin-left: 0.3125em; padding: 4px 0px;"&gt;&lt;SPAN class="" style="padding: 0px 5px;"&gt;&lt;A href="https://developers.arcgis.com/javascript/latest/api-reference/esri-views-View.html" style="color: #0079c1; text-decoration: none;"&gt;View&lt;/A&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/DIV&gt;&lt;P&gt;&lt;SPAN class="" style="color: #4c4c4c; background-color: #efefef; border: 1px solid #cccccc; font-weight: 300; margin-bottom: 0.625rem; padding: 2px 4px;"&gt;optional&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="color: #4c4c4c; background-color: #ffffff; font-weight: 300; margin: 0.5rem 0px;"&gt;A&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;A href="https://developers.arcgis.com/javascript/latest/api-reference/esri-views-SceneView.html" style="color: #0079c1; text-decoration: none;"&gt;SceneView&lt;/A&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;or&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;A href="https://developers.arcgis.com/javascript/latest/api-reference/esri-views-MapView.html" style="color: #0079c1; text-decoration: none;"&gt;MapView&lt;/A&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;instance is required when a&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;CODE style="color: #595959; background-color: #f8f8f8; border: 1px solid #efefef; font-size: 0.875em;"&gt;valueExpression&lt;/CODE&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;is specified.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So what I had to do was this:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="background-color: #ffffff; border: 0px;"&gt;uniqueValues({&lt;BR /&gt;layer: layer,&lt;BR /&gt;field: "sStatus",&lt;/P&gt;&lt;P style="background-color: #ffffff; border: 0px;"&gt;&lt;STRONG&gt;view: mapView&lt;/STRONG&gt;&lt;BR /&gt;}).then(function (response) {&lt;BR /&gt;// prints each unique value and the count of features containing that value&lt;BR /&gt;var infos = response.uniqueValueInfos;&lt;/P&gt;&lt;P style="background-color: #ffffff; border: 0px;"&gt;console.log('test');&lt;/P&gt;&lt;P style="background-color: #ffffff; border: 0px;"&gt;infos.forEach(function (info) {&lt;BR /&gt;console.log("Wells : ", info.value, " # OF CAMPAIGN STOPS: ", info.count);&lt;BR /&gt;});&lt;BR /&gt;}).catch(errback);&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 24 Jan 2019 20:14:36 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/uniquevalues-function-error/m-p/262824#M24375</guid>
      <dc:creator>LenielMaccaferri</dc:creator>
      <dc:date>2019-01-24T20:14:36Z</dc:date>
    </item>
  </channel>
</rss>

