<?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 data expression failed to fetch error in ArcGIS Dashboards Questions</title>
    <link>https://community.esri.com/t5/arcgis-dashboards-questions/data-expression-failed-to-fetch-error/m-p/1500284#M9909</link>
    <description>&lt;P&gt;Good morning,&lt;/P&gt;&lt;P&gt;I am looking for a little help with setting up a data expression to use as the source of an indicator.&amp;nbsp; I am looking to have the indicator return the number of days between 2 date fields (DateTimeInit and DateTimeClosed. I am also looking to have the expression pull in 2 other data fields from the feature layer, request id and description to set up other indicators such as average number of days to close for each type of request.&amp;nbsp; Every time I test the expression I get the following error -&amp;nbsp;&lt;SPAN class=""&gt;Execution Error:&lt;/SPAN&gt;&lt;SPAN&gt;Failed to fetch&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;This is the expression I have thus far;&lt;/P&gt;&lt;P&gt;//Pull in data from Closed Service Request feature layer&lt;BR /&gt;var portal = Portal('https:myurl');&lt;BR /&gt;var fs = FeatureSetByPortalItem(&lt;BR /&gt;portal,&lt;BR /&gt;'xx310x708a80409x960xx06e6xx0e8e6',&lt;BR /&gt;0,&lt;BR /&gt;['RequestId',&lt;BR /&gt;'Description',&lt;BR /&gt;'DateTimeInit',&lt;BR /&gt;'DateTimeClosed'&lt;BR /&gt;&lt;BR /&gt;],&lt;BR /&gt;false&lt;BR /&gt;);&lt;/P&gt;&lt;P&gt;var StartDate = Date(fs,'DateTimeInit')&lt;BR /&gt;var EndDate = Date(fs,'DateTimeClosed')&lt;/P&gt;&lt;P&gt;//Create empty Dictionary&lt;BR /&gt;var fsDict = {&lt;BR /&gt;'fields': [&lt;BR /&gt;{'name': 'RequestId', 'type': 'esriFieldTypeString'},&lt;BR /&gt;{'name': 'Description', 'type': 'esriFieldTypeString'},&lt;BR /&gt;{'name': 'DateTimeInit', 'type': 'esriFieldTypeDate'},&lt;BR /&gt;{'name': 'DateTimeClosed', 'type': 'esriFieldTypeDate'},&lt;BR /&gt;{'name': 'DaysToClose', 'type': 'esriFieldTypeInteger'},&lt;BR /&gt;],&lt;BR /&gt;'geometryType': '',&lt;BR /&gt;'features':[]&lt;BR /&gt;};&lt;/P&gt;&lt;P&gt;var index = 0;&lt;/P&gt;&lt;P&gt;//Loop through features in the featureset to populate the dictionary&lt;BR /&gt;for (var feature in fs) {&lt;BR /&gt;fsDict.features[index++] = {&lt;BR /&gt;'attributes': {&lt;BR /&gt;'RequestId': feature['RequestId'],&lt;BR /&gt;'Description': feature['Description'],&lt;BR /&gt;'DateTimeInit': feature['DateTimeInit'],&lt;BR /&gt;'DateTimeClosed': feature['DateTimeClosed'],&lt;BR /&gt;'DaysToClose': DateDiff ([EndDate] -[StartDate], 'days')&lt;BR /&gt;}&lt;BR /&gt;}&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;//return dictionary&lt;BR /&gt;return FeatureSet(Text(fsDict));&lt;/P&gt;</description>
    <pubDate>Tue, 02 Jul 2024 13:32:30 GMT</pubDate>
    <dc:creator>RobertMateja</dc:creator>
    <dc:date>2024-07-02T13:32:30Z</dc:date>
    <item>
      <title>data expression failed to fetch error</title>
      <link>https://community.esri.com/t5/arcgis-dashboards-questions/data-expression-failed-to-fetch-error/m-p/1500284#M9909</link>
      <description>&lt;P&gt;Good morning,&lt;/P&gt;&lt;P&gt;I am looking for a little help with setting up a data expression to use as the source of an indicator.&amp;nbsp; I am looking to have the indicator return the number of days between 2 date fields (DateTimeInit and DateTimeClosed. I am also looking to have the expression pull in 2 other data fields from the feature layer, request id and description to set up other indicators such as average number of days to close for each type of request.&amp;nbsp; Every time I test the expression I get the following error -&amp;nbsp;&lt;SPAN class=""&gt;Execution Error:&lt;/SPAN&gt;&lt;SPAN&gt;Failed to fetch&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;This is the expression I have thus far;&lt;/P&gt;&lt;P&gt;//Pull in data from Closed Service Request feature layer&lt;BR /&gt;var portal = Portal('https:myurl');&lt;BR /&gt;var fs = FeatureSetByPortalItem(&lt;BR /&gt;portal,&lt;BR /&gt;'xx310x708a80409x960xx06e6xx0e8e6',&lt;BR /&gt;0,&lt;BR /&gt;['RequestId',&lt;BR /&gt;'Description',&lt;BR /&gt;'DateTimeInit',&lt;BR /&gt;'DateTimeClosed'&lt;BR /&gt;&lt;BR /&gt;],&lt;BR /&gt;false&lt;BR /&gt;);&lt;/P&gt;&lt;P&gt;var StartDate = Date(fs,'DateTimeInit')&lt;BR /&gt;var EndDate = Date(fs,'DateTimeClosed')&lt;/P&gt;&lt;P&gt;//Create empty Dictionary&lt;BR /&gt;var fsDict = {&lt;BR /&gt;'fields': [&lt;BR /&gt;{'name': 'RequestId', 'type': 'esriFieldTypeString'},&lt;BR /&gt;{'name': 'Description', 'type': 'esriFieldTypeString'},&lt;BR /&gt;{'name': 'DateTimeInit', 'type': 'esriFieldTypeDate'},&lt;BR /&gt;{'name': 'DateTimeClosed', 'type': 'esriFieldTypeDate'},&lt;BR /&gt;{'name': 'DaysToClose', 'type': 'esriFieldTypeInteger'},&lt;BR /&gt;],&lt;BR /&gt;'geometryType': '',&lt;BR /&gt;'features':[]&lt;BR /&gt;};&lt;/P&gt;&lt;P&gt;var index = 0;&lt;/P&gt;&lt;P&gt;//Loop through features in the featureset to populate the dictionary&lt;BR /&gt;for (var feature in fs) {&lt;BR /&gt;fsDict.features[index++] = {&lt;BR /&gt;'attributes': {&lt;BR /&gt;'RequestId': feature['RequestId'],&lt;BR /&gt;'Description': feature['Description'],&lt;BR /&gt;'DateTimeInit': feature['DateTimeInit'],&lt;BR /&gt;'DateTimeClosed': feature['DateTimeClosed'],&lt;BR /&gt;'DaysToClose': DateDiff ([EndDate] -[StartDate], 'days')&lt;BR /&gt;}&lt;BR /&gt;}&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;//return dictionary&lt;BR /&gt;return FeatureSet(Text(fsDict));&lt;/P&gt;</description>
      <pubDate>Tue, 02 Jul 2024 13:32:30 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-dashboards-questions/data-expression-failed-to-fetch-error/m-p/1500284#M9909</guid>
      <dc:creator>RobertMateja</dc:creator>
      <dc:date>2024-07-02T13:32:30Z</dc:date>
    </item>
    <item>
      <title>Re: data expression failed to fetch error</title>
      <link>https://community.esri.com/t5/arcgis-dashboards-questions/data-expression-failed-to-fetch-error/m-p/1500315#M9910</link>
      <description>&lt;P&gt;Can you try to put &lt;STRONG&gt;return fs&lt;/STRONG&gt; right after your FeatureSetByPortalItem function? If your expression isn't even connecting to the data source, the rest of the expression doesn't matter.&lt;/P&gt;&lt;P&gt;Looking at your expression, you'll need to adjust your DaysToClose expression near the end. You're not listing your parameters correctly. If your expression gets down to that line once your initial problem is fixed, it will give you another error.&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;'DaysToClose': DateDiff(EndDate, StartDate, 'days')&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;Also, I'm not sure what you're attempting when you create the variables StartDate and EndDate. Calling the &lt;STRONG&gt;Date&lt;/STRONG&gt; function against an entire featureset won't give you anything. You need to somehow specify an individual feature to pull the date from. Perhaps the start and end dates are meant to be in the for loop?&lt;/P&gt;</description>
      <pubDate>Tue, 02 Jul 2024 14:01:50 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-dashboards-questions/data-expression-failed-to-fetch-error/m-p/1500315#M9910</guid>
      <dc:creator>jcarlson</dc:creator>
      <dc:date>2024-07-02T14:01:50Z</dc:date>
    </item>
    <item>
      <title>Re: data expression failed to fetch error</title>
      <link>https://community.esri.com/t5/arcgis-dashboards-questions/data-expression-failed-to-fetch-error/m-p/1500387#M9911</link>
      <description>&lt;P&gt;Josh,&lt;/P&gt;&lt;P&gt;I put the &lt;STRONG&gt;return fs&lt;/STRONG&gt; right after the FeatureSetByPortalItem function as you suggested and no data is returned.&amp;nbsp; I guess I need to figure that out.&amp;nbsp; If I change the portalitem to a different feature layer it works without issue.&amp;nbsp; I guess I will need to figure out what is going on with this specific feature layer.&amp;nbsp; Thanks for the help.&amp;nbsp; I&amp;nbsp; am sure I will be back once I get this issue resolved.&lt;/P&gt;&lt;P&gt;rob&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 02 Jul 2024 15:53:10 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-dashboards-questions/data-expression-failed-to-fetch-error/m-p/1500387#M9911</guid>
      <dc:creator>RobertMateja</dc:creator>
      <dc:date>2024-07-02T15:53:10Z</dc:date>
    </item>
  </channel>
</rss>

