<?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 Custom Widget Filter Not Persistent in Experience Builder Custom Widgets</title>
    <link>https://community.esri.com/t5/experience-builder-custom-widgets/custom-widget-filter-not-persistent/m-p/1638509#M618</link>
    <description>&lt;P&gt;Hello,&lt;BR /&gt;I made a custom widget to simplify the filtering process, it applies the filter just fine (for example, filtering by state will filter out all but the selected states in a drop down menu) but the moment I click any of the feature polygons in the map to see the attributes of that feature, the filter disappears and I can see all the states again.&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;Here are the relevant parts of my code:&lt;/P&gt;&lt;LI-CODE lang="python"&gt;// Apply filter function from BlocksBeadFilter.tsx
const addFilter = (): void =&amp;gt; {
  if (!layerInfo) return
  const lyr = layerInfo.lyr

  // Build age clause
  const ageClause = (() =&amp;gt; {
    if (!ageSelected.length || ageMin.value &amp;lt;= 0) return ''
    const flds = ageSelected.flatMap(l =&amp;gt; ageMap[l] || [])
    return flds.length ? `(${flds.map(f =&amp;gt; `${f} &amp;gt; ${ageMin.value}`).join(' OR ')})` : ''
  })()

  // Build all clauses
  const clauses = [
    buildInClause('ProviderName', provider.selected),
    buildInClause('StateName', state.selected),
    buildInClause('CountyName', county.selected),
    ageClause,
    buildGroupClause(bslSelected, bslMin.value, f =&amp;gt; f),
    buildGroupClause(raceSelected, raceMin.value, lbl =&amp;gt; raceMap[lbl]),
    buildIncomeClause(incMin.value, incMax.value)
  ].filter(Boolean)

  lyr.definitionExpression = clauses.join(' AND ')
  
  // Clear all widget selections after applying the filter
  clearWidgetSelections()
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;// From filterUtils.ts
export const buildInClause = (field: string, values: string[]): string =&amp;gt; {
  if (!values.length) return ''
  return `${field} IN (${values.map(val =&amp;gt; `'${val.replace(/'/g, "''")}'`).join(', ')})`
}

export const buildGroupClause = (
  arr: string[], 
  min: number, 
  getField: (s: string) =&amp;gt; string
): string =&amp;gt; {
  return (arr.length &amp;amp;&amp;amp; min &amp;gt; 0) 
    ? `(${arr.map(a =&amp;gt; `${getField(a)} &amp;gt; ${min}`).join(' OR ')})` 
    : ''
}

export const buildIncomeClause = (incMin: number, incMax: number): string =&amp;gt; {
  const parts: string[] = []
  if (incMin &amp;gt; 0) parts.push(`ASQPE001 &amp;gt;= ${incMin}`)
  if (incMax &amp;gt; 0) parts.push(`ASQPE001 &amp;lt;= ${incMax}`)
  return parts.length ? `(${parts.join(' AND ')})` : ''
}&lt;/LI-CODE&gt;&lt;P&gt;&lt;BR /&gt;&amp;nbsp;Thank you for your advice.&lt;/P&gt;</description>
    <pubDate>Fri, 01 Aug 2025 18:53:29 GMT</pubDate>
    <dc:creator>TristanJonas</dc:creator>
    <dc:date>2025-08-01T18:53:29Z</dc:date>
    <item>
      <title>Custom Widget Filter Not Persistent</title>
      <link>https://community.esri.com/t5/experience-builder-custom-widgets/custom-widget-filter-not-persistent/m-p/1638509#M618</link>
      <description>&lt;P&gt;Hello,&lt;BR /&gt;I made a custom widget to simplify the filtering process, it applies the filter just fine (for example, filtering by state will filter out all but the selected states in a drop down menu) but the moment I click any of the feature polygons in the map to see the attributes of that feature, the filter disappears and I can see all the states again.&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;Here are the relevant parts of my code:&lt;/P&gt;&lt;LI-CODE lang="python"&gt;// Apply filter function from BlocksBeadFilter.tsx
const addFilter = (): void =&amp;gt; {
  if (!layerInfo) return
  const lyr = layerInfo.lyr

  // Build age clause
  const ageClause = (() =&amp;gt; {
    if (!ageSelected.length || ageMin.value &amp;lt;= 0) return ''
    const flds = ageSelected.flatMap(l =&amp;gt; ageMap[l] || [])
    return flds.length ? `(${flds.map(f =&amp;gt; `${f} &amp;gt; ${ageMin.value}`).join(' OR ')})` : ''
  })()

  // Build all clauses
  const clauses = [
    buildInClause('ProviderName', provider.selected),
    buildInClause('StateName', state.selected),
    buildInClause('CountyName', county.selected),
    ageClause,
    buildGroupClause(bslSelected, bslMin.value, f =&amp;gt; f),
    buildGroupClause(raceSelected, raceMin.value, lbl =&amp;gt; raceMap[lbl]),
    buildIncomeClause(incMin.value, incMax.value)
  ].filter(Boolean)

  lyr.definitionExpression = clauses.join(' AND ')
  
  // Clear all widget selections after applying the filter
  clearWidgetSelections()
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;// From filterUtils.ts
export const buildInClause = (field: string, values: string[]): string =&amp;gt; {
  if (!values.length) return ''
  return `${field} IN (${values.map(val =&amp;gt; `'${val.replace(/'/g, "''")}'`).join(', ')})`
}

export const buildGroupClause = (
  arr: string[], 
  min: number, 
  getField: (s: string) =&amp;gt; string
): string =&amp;gt; {
  return (arr.length &amp;amp;&amp;amp; min &amp;gt; 0) 
    ? `(${arr.map(a =&amp;gt; `${getField(a)} &amp;gt; ${min}`).join(' OR ')})` 
    : ''
}

export const buildIncomeClause = (incMin: number, incMax: number): string =&amp;gt; {
  const parts: string[] = []
  if (incMin &amp;gt; 0) parts.push(`ASQPE001 &amp;gt;= ${incMin}`)
  if (incMax &amp;gt; 0) parts.push(`ASQPE001 &amp;lt;= ${incMax}`)
  return parts.length ? `(${parts.join(' AND ')})` : ''
}&lt;/LI-CODE&gt;&lt;P&gt;&lt;BR /&gt;&amp;nbsp;Thank you for your advice.&lt;/P&gt;</description>
      <pubDate>Fri, 01 Aug 2025 18:53:29 GMT</pubDate>
      <guid>https://community.esri.com/t5/experience-builder-custom-widgets/custom-widget-filter-not-persistent/m-p/1638509#M618</guid>
      <dc:creator>TristanJonas</dc:creator>
      <dc:date>2025-08-01T18:53:29Z</dc:date>
    </item>
    <item>
      <title>Re: Custom Widget Filter Not Persistent</title>
      <link>https://community.esri.com/t5/experience-builder-custom-widgets/custom-widget-filter-not-persistent/m-p/1641773#M626</link>
      <description>&lt;P&gt;So if you are making changes in a custom widget, does the custom widget communicate to any other widgets in the experience? (This likely would be an 'action' of some kind) Depending on the behavior you want it might be an selection update that needs to be fired from the custom widget and subscribed to by the other widget (map perhaps in this case)&lt;BR /&gt;&lt;BR /&gt;You may want to check out one of these:&lt;BR /&gt;&lt;BR /&gt;&lt;A href="https://doc.arcgis.com/en/experience-builder/latest/configure-widgets/action-triggers.htm" target="_blank"&gt;https://doc.arcgis.com/en/experience-builder/latest/configure-widgets/action-triggers.htm&lt;/A&gt;&lt;BR /&gt;&lt;A href="https://community.esri.com/t5/arcgis-experience-builder-questions/add-a-custom-action-in-built-in-esri-s-widget/m-p/1563645" target="_blank"&gt;https://community.esri.com/t5/arcgis-experience-builder-questions/add-a-custom-action-in-built-in-esri-s-widget/m-p/1563645&lt;/A&gt;&lt;BR /&gt;&lt;A href="https://community.esri.com/t5/arcgis-experience-builder-questions/triggering-data-actions-from-a-custom-widget/td-p/1215506/page/2" target="_blank"&gt;https://community.esri.com/t5/arcgis-experience-builder-questions/triggering-data-actions-from-a-custom-widget/td-p/1215506/page/2&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 13 Aug 2025 20:43:43 GMT</pubDate>
      <guid>https://community.esri.com/t5/experience-builder-custom-widgets/custom-widget-filter-not-persistent/m-p/1641773#M626</guid>
      <dc:creator>TimWestern</dc:creator>
      <dc:date>2025-08-13T20:43:43Z</dc:date>
    </item>
    <item>
      <title>Re: Custom Widget Filter Not Persistent</title>
      <link>https://community.esri.com/t5/experience-builder-custom-widgets/custom-widget-filter-not-persistent/m-p/1641775#M627</link>
      <description>&lt;P&gt;&lt;A href="https://community.esri.com/t5/arcgis-experience-builder-questions/print-widget-failing-with-map-service-layer-in/m-p/1639304#M20307" target="_blank"&gt;https://community.esri.com/t5/arcgis-experience-builder-questions/print-widget-failing-with-map-service-layer-in/m-p/1639304#M20307&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 13 Aug 2025 20:46:55 GMT</pubDate>
      <guid>https://community.esri.com/t5/experience-builder-custom-widgets/custom-widget-filter-not-persistent/m-p/1641775#M627</guid>
      <dc:creator>TimWestern</dc:creator>
      <dc:date>2025-08-13T20:46:55Z</dc:date>
    </item>
  </channel>
</rss>

