<?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: Unable to refresh Feature Layer and see symbology change in ArcGIS Experience Builder Questions</title>
    <link>https://community.esri.com/t5/arcgis-experience-builder-questions/unable-to-refresh-feature-layer-and-see-symbology/m-p/1240554#M5901</link>
    <description>&lt;LI-CODE lang="c"&gt;const layer_views = this.state.jimuMapView.view.allLayerViews;

layer_views.forEach((lyr_view) =&amp;gt; { 
    const lyr = lyr_view.layer; 
    if (lyr.type === "feature") { 
        lyr.refresh(); 
    } 
});&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This works to refresh the graphics.&amp;nbsp; We have to reference the Layer associated with the LayerView shown in the MapView.&amp;nbsp; Technically we can access the Feature Layer from the DataSources, but those layers are not aware of their LayerViews.&amp;nbsp; So to refresh the LayerView we must use the layer object directly associated with it.&lt;/P&gt;</description>
    <pubDate>Tue, 13 Dec 2022 12:40:04 GMT</pubDate>
    <dc:creator>rhughes522</dc:creator>
    <dc:date>2022-12-13T12:40:04Z</dc:date>
    <item>
      <title>Unable to refresh Feature Layer and see symbology change</title>
      <link>https://community.esri.com/t5/arcgis-experience-builder-questions/unable-to-refresh-feature-layer-and-see-symbology/m-p/1238538#M5863</link>
      <description>&lt;P&gt;Using the jsapi 4.24 in the Dev ExB v1.9.0.&lt;/P&gt;&lt;P&gt;In a custom widget I am editing a hosted Feature Layer - success&lt;/P&gt;&lt;P&gt;Then I need to refresh the layer in the MapView.&amp;nbsp; I call layer.refresh(), and when I view the on("refresh") event properties it does say dataUpdated.&amp;nbsp; However, the graphics don't change in the LayerView.&amp;nbsp; The only way I can get the graphics to change is by zooming in/out.&lt;/P&gt;&lt;P&gt;Before I try to remove and re-add the layers, i am interested in finding out if this FeatureLayer.refresh() method is supposed to also update the Feature Layer View.&amp;nbsp; Based on the comments in the searches online I think it should.&lt;/P&gt;&lt;P&gt;Does Experience Builder have it's own FeatureLayer refresh() method that I need to use instead?&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'd really like to update the LayerView graphics without needing to change the map zoom level.&lt;/P&gt;</description>
      <pubDate>Tue, 06 Dec 2022 22:54:11 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-experience-builder-questions/unable-to-refresh-feature-layer-and-see-symbology/m-p/1238538#M5863</guid>
      <dc:creator>rhughes522</dc:creator>
      <dc:date>2022-12-06T22:54:11Z</dc:date>
    </item>
    <item>
      <title>Re: Unable to refresh Feature Layer and see symbology change</title>
      <link>https://community.esri.com/t5/arcgis-experience-builder-questions/unable-to-refresh-feature-layer-and-see-symbology/m-p/1238541#M5864</link>
      <description>&lt;P&gt;i am doing some cleanup with the Promises that are running before the refresh() to make sure all the editing has completed.&amp;nbsp; I think it's possible that not all the edit calls completed before the refresh() gets run.&lt;/P&gt;</description>
      <pubDate>Tue, 06 Dec 2022 23:03:54 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-experience-builder-questions/unable-to-refresh-feature-layer-and-see-symbology/m-p/1238541#M5864</guid>
      <dc:creator>rhughes522</dc:creator>
      <dc:date>2022-12-06T23:03:54Z</dc:date>
    </item>
    <item>
      <title>Re: Unable to refresh Feature Layer and see symbology change</title>
      <link>https://community.esri.com/t5/arcgis-experience-builder-questions/unable-to-refresh-feature-layer-and-see-symbology/m-p/1238543#M5865</link>
      <description>&lt;P&gt;No change after implementing Promise.all() on the list of promises resolved after each applyEdits.&amp;nbsp; The edited feature oids (update only) are successfully returned by the Promise before I run the refresh() method. I will try and post my widget code.&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;performUpdate = (envelope_layer: FeatureLayer, turbine_layer: FeatureLayer, queryParams: Query, is_base_case: number) =&amp;gt; {
    const promise1 = new Promise((resolve, reject) =&amp;gt; {
      envelope_layer.queryFeatures(queryParams).then(function(result) {
        console.log(result.features);
        // set is_base_case to false on each features and collect object ids
        const oids = [];
        result.features.forEach(element =&amp;gt; {
          element.attributes["is_base_case"] = is_base_case;
          oids.push(element.attributes["objectid"]);
        });
        // edit the layer with the updated features
        envelope_layer.applyEdits({
          updateFeatures: result.features
        }).then(function() {
          // query the related turbine features and update is_base_case
          const rel_query = {
            outFields: ["*"],
            relationshipId: 0,
            objectIds: oids
          }

          envelope_layer.queryRelatedFeatures(rel_query).then(function(result) {
            let promises = [];
            oids.forEach(oid =&amp;gt; {
              const prom = new Promise((resolve2, reject2) =&amp;gt; {
                if (result[oid]) {
                  console.group("relationship for feature:", oid);
                  const turbine_feats = result[oid].features;
                  // set the is_base_case on features to false
                  turbine_feats.forEach(feat =&amp;gt; {
                    console.log("attributes", JSON.stringify(feat.attributes));
                    feat.attributes["is_base_case"] = is_base_case;
                  });
                  // edit the turbine layer with the updated turbine features
                  turbine_layer.applyEdits({
                    updateFeatures: turbine_feats
                  }).then((editResult) =&amp;gt; {
                    resolve2(editResult);
                    console.groupEnd();
                  }).catch((error) =&amp;gt; {
                    console.log("error =", error);
                    reject2(error);
                  });
                }
              });
              promises.push(prom);
            });
            Promise.all(promises).then((values) =&amp;gt; {
              resolve('complete');
            });
            
          }).catch(function (error) {
            console.log("error from queryRelatedFeatures", error);
            reject(error);
          });
        });
      });
    });
    return promise1;
  };
  
  updateLayers = (envelope_layer: FeatureLayer, turbine_layer: FeatureLayer, project_name: string, layout_name: string) =&amp;gt; {
    // set the Base Case first on the Envelope layer then query related features to update 
    // Base Case attribute on the turbine points for each layout
    const non_matching_query = `name_project = '${project_name}' AND id_layout &amp;lt;&amp;gt; '${layout_name}'`;
    const matching_query = `name_project = '${project_name}' AND id_layout = '${layout_name}'`;
    const non_matching_queryParams = envelope_layer.createQuery();
    const matching_queryParams = envelope_layer.createQuery();
    // query features from the project that do match layout name as set as true
    non_matching_queryParams.where = non_matching_query
    non_matching_queryParams.returnGeometry = false;
    this.performUpdate(envelope_layer, turbine_layer, non_matching_queryParams, 0).then((result) =&amp;gt; {
      matching_queryParams.where = matching_query;
      matching_queryParams.returnGeometry = false;
      this.performUpdate(envelope_layer, turbine_layer, matching_queryParams, 1).then((result) =&amp;gt; {
        // refresh the layer Views
        // turbine_layer.on("refresh", function(event) {
        //   console.log(event);
        // });
      
        turbine_layer.refresh();
        
        // envelope_layer.refresh();
        
      });
    });

    
    
  };&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 06 Dec 2022 23:18:17 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-experience-builder-questions/unable-to-refresh-feature-layer-and-see-symbology/m-p/1238543#M5865</guid>
      <dc:creator>rhughes522</dc:creator>
      <dc:date>2022-12-06T23:18:17Z</dc:date>
    </item>
    <item>
      <title>Re: Unable to refresh Feature Layer and see symbology change</title>
      <link>https://community.esri.com/t5/arcgis-experience-builder-questions/unable-to-refresh-feature-layer-and-see-symbology/m-p/1240554#M5901</link>
      <description>&lt;LI-CODE lang="c"&gt;const layer_views = this.state.jimuMapView.view.allLayerViews;

layer_views.forEach((lyr_view) =&amp;gt; { 
    const lyr = lyr_view.layer; 
    if (lyr.type === "feature") { 
        lyr.refresh(); 
    } 
});&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This works to refresh the graphics.&amp;nbsp; We have to reference the Layer associated with the LayerView shown in the MapView.&amp;nbsp; Technically we can access the Feature Layer from the DataSources, but those layers are not aware of their LayerViews.&amp;nbsp; So to refresh the LayerView we must use the layer object directly associated with it.&lt;/P&gt;</description>
      <pubDate>Tue, 13 Dec 2022 12:40:04 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-experience-builder-questions/unable-to-refresh-feature-layer-and-see-symbology/m-p/1240554#M5901</guid>
      <dc:creator>rhughes522</dc:creator>
      <dc:date>2022-12-13T12:40:04Z</dc:date>
    </item>
  </channel>
</rss>

