<?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 Help! search() function not working as documented in ArcGIS Survey123 Questions</title>
    <link>https://community.esri.com/t5/arcgis-survey123-questions/help-search-function-not-working-as-documented/m-p/1265658#M47866</link>
    <description>&lt;P&gt;Hey all,&lt;/P&gt;&lt;P&gt;Hoping someone can help figure out why the search() function isn't working as documented.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Overview&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;I have a hosted feature layer that contains a parent table with event details, and a child table which has attendees that can be recorded for that event via a repeat.&lt;/P&gt;&lt;P&gt;I'm trying to put together a search query that can generate a list of attendees for a specific event based on parentglobalid's.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Looking at the &lt;A href="https://doc.arcgis.com/en/survey123/desktop/create-surveys/xlsformsappearance.htm#ESRI_SECTION1_46A700D2AABF47F1AE4D5004762DB372" target="_self"&gt;documentation for the search() function&lt;/A&gt;, an example query was the following:&lt;/P&gt;&lt;BLOCKQUOTE&gt;&lt;P&gt;&lt;SPAN&gt;search('csvName', 'matches', 'breed', ${DogQuestion})&lt;/SPAN&gt;&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;I put together a very similar query as follows (except I call the related table instead of a csv):&lt;/P&gt;&lt;BLOCKQUOTE&gt;&lt;P&gt;search('example_search?url=&amp;lt;REST url&amp;gt;/FeatureServer/3', 'matches', 'parentglobalid', ${parentglobalid})&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;The searchColumn "parentglobalid" is the name of the field in the related table, and the searchText of ${parentglobalid} refers to a question in the survey that stores the parentglobalid.&amp;nbsp;&lt;/P&gt;&lt;P&gt;In theory, this should work however it returns a list of&amp;nbsp;&lt;STRONG&gt;all&amp;nbsp;&lt;/STRONG&gt;records from the attendance field instead of just the ones that match the parentglobalid:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Vinzafy_0-1678302007366.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/64732iB3B51DA086241A12/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Vinzafy_0-1678302007366.png" alt="Vinzafy_0-1678302007366.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;To check that this search query is correct, I replaced ${parentglobalid} with an actual value for a parentglobalid in the feature layer and this worked as expected - only attendees for that specific event were returned:&lt;/P&gt;&lt;BLOCKQUOTE&gt;&lt;P&gt;search('example_search?url=&amp;lt;REST url&amp;gt;/FeatureServer/3', 'matches', 'parentglobalid', '57ad118f-bcb0-41a1-8268-c2d2b7f79512')&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Vinzafy_1-1678302115138.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/64733i3A2761FD8C21626B/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Vinzafy_1-1678302115138.png" alt="Vinzafy_1-1678302115138.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;It seems the search() function only works when the searchText is a string enclosed in quotes (static), however the documentation shows that it can reference a field (dynamic) but that's not working in my case.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Troubleshooting Attempts&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;The things I've tried are the following (none of them worked):&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;Create a separate text question that stores the parentglobalid a second time and call that in the search() function&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;&lt;/LI&gt;&lt;LI&gt;In that separate text question, ensure the parentglobalid is a string and call that in the search() function&lt;BR /&gt;&lt;BR /&gt;&lt;/LI&gt;&lt;LI&gt;In that separate text question, enclose the parentglobalid with quotation marks ( concat("'", ${parentglobalid}, "'") ) and call that in the search() function&lt;BR /&gt;&lt;BR /&gt;&lt;/LI&gt;&lt;LI&gt;Call a completely irrelevant field as the serachText value which still returns the entire list&lt;BR /&gt;&lt;BR /&gt;&lt;/LI&gt;&lt;LI&gt;Have a separate calculate question that stores the ensure search() function and have the appearance call that calculated value&lt;BR /&gt;&lt;BR /&gt;&lt;/LI&gt;&lt;LI&gt;Have a separate calculate question that stores the body of the search() function and have the appearance call the calculate within the search function (e.g., search(${search_body})&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;Hopefully I'm missing something straightforward and this is a quick fix. Or maybe it's not possible to run the search() function using parentglobalid's, however it just doesn't seem to want to work when calling a field dynamically.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any help or advice would be much appreciated!&lt;/P&gt;</description>
    <pubDate>Wed, 08 Mar 2023 19:09:58 GMT</pubDate>
    <dc:creator>Vince_ERAC</dc:creator>
    <dc:date>2023-03-08T19:09:58Z</dc:date>
    <item>
      <title>Help! search() function not working as documented</title>
      <link>https://community.esri.com/t5/arcgis-survey123-questions/help-search-function-not-working-as-documented/m-p/1265658#M47866</link>
      <description>&lt;P&gt;Hey all,&lt;/P&gt;&lt;P&gt;Hoping someone can help figure out why the search() function isn't working as documented.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Overview&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;I have a hosted feature layer that contains a parent table with event details, and a child table which has attendees that can be recorded for that event via a repeat.&lt;/P&gt;&lt;P&gt;I'm trying to put together a search query that can generate a list of attendees for a specific event based on parentglobalid's.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Looking at the &lt;A href="https://doc.arcgis.com/en/survey123/desktop/create-surveys/xlsformsappearance.htm#ESRI_SECTION1_46A700D2AABF47F1AE4D5004762DB372" target="_self"&gt;documentation for the search() function&lt;/A&gt;, an example query was the following:&lt;/P&gt;&lt;BLOCKQUOTE&gt;&lt;P&gt;&lt;SPAN&gt;search('csvName', 'matches', 'breed', ${DogQuestion})&lt;/SPAN&gt;&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;I put together a very similar query as follows (except I call the related table instead of a csv):&lt;/P&gt;&lt;BLOCKQUOTE&gt;&lt;P&gt;search('example_search?url=&amp;lt;REST url&amp;gt;/FeatureServer/3', 'matches', 'parentglobalid', ${parentglobalid})&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;The searchColumn "parentglobalid" is the name of the field in the related table, and the searchText of ${parentglobalid} refers to a question in the survey that stores the parentglobalid.&amp;nbsp;&lt;/P&gt;&lt;P&gt;In theory, this should work however it returns a list of&amp;nbsp;&lt;STRONG&gt;all&amp;nbsp;&lt;/STRONG&gt;records from the attendance field instead of just the ones that match the parentglobalid:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Vinzafy_0-1678302007366.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/64732iB3B51DA086241A12/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Vinzafy_0-1678302007366.png" alt="Vinzafy_0-1678302007366.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;To check that this search query is correct, I replaced ${parentglobalid} with an actual value for a parentglobalid in the feature layer and this worked as expected - only attendees for that specific event were returned:&lt;/P&gt;&lt;BLOCKQUOTE&gt;&lt;P&gt;search('example_search?url=&amp;lt;REST url&amp;gt;/FeatureServer/3', 'matches', 'parentglobalid', '57ad118f-bcb0-41a1-8268-c2d2b7f79512')&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Vinzafy_1-1678302115138.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/64733i3A2761FD8C21626B/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Vinzafy_1-1678302115138.png" alt="Vinzafy_1-1678302115138.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;It seems the search() function only works when the searchText is a string enclosed in quotes (static), however the documentation shows that it can reference a field (dynamic) but that's not working in my case.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Troubleshooting Attempts&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;The things I've tried are the following (none of them worked):&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;Create a separate text question that stores the parentglobalid a second time and call that in the search() function&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;&lt;/LI&gt;&lt;LI&gt;In that separate text question, ensure the parentglobalid is a string and call that in the search() function&lt;BR /&gt;&lt;BR /&gt;&lt;/LI&gt;&lt;LI&gt;In that separate text question, enclose the parentglobalid with quotation marks ( concat("'", ${parentglobalid}, "'") ) and call that in the search() function&lt;BR /&gt;&lt;BR /&gt;&lt;/LI&gt;&lt;LI&gt;Call a completely irrelevant field as the serachText value which still returns the entire list&lt;BR /&gt;&lt;BR /&gt;&lt;/LI&gt;&lt;LI&gt;Have a separate calculate question that stores the ensure search() function and have the appearance call that calculated value&lt;BR /&gt;&lt;BR /&gt;&lt;/LI&gt;&lt;LI&gt;Have a separate calculate question that stores the body of the search() function and have the appearance call the calculate within the search function (e.g., search(${search_body})&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;Hopefully I'm missing something straightforward and this is a quick fix. Or maybe it's not possible to run the search() function using parentglobalid's, however it just doesn't seem to want to work when calling a field dynamically.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any help or advice would be much appreciated!&lt;/P&gt;</description>
      <pubDate>Wed, 08 Mar 2023 19:09:58 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-survey123-questions/help-search-function-not-working-as-documented/m-p/1265658#M47866</guid>
      <dc:creator>Vince_ERAC</dc:creator>
      <dc:date>2023-03-08T19:09:58Z</dc:date>
    </item>
    <item>
      <title>Re: Help! search() function not working as documented</title>
      <link>https://community.esri.com/t5/arcgis-survey123-questions/help-search-function-not-working-as-documented/m-p/1302136#M50183</link>
      <description>&lt;P&gt;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/8751"&gt;@Vince_ERAC&lt;/a&gt;&amp;nbsp;- did you ever get this working? I'm having a similar problem with a GUID.&lt;/P&gt;</description>
      <pubDate>Thu, 22 Jun 2023 17:32:24 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-survey123-questions/help-search-function-not-working-as-documented/m-p/1302136#M50183</guid>
      <dc:creator>JJ_Reyes</dc:creator>
      <dc:date>2023-06-22T17:32:24Z</dc:date>
    </item>
    <item>
      <title>Re: Help! search() function not working as documented</title>
      <link>https://community.esri.com/t5/arcgis-survey123-questions/help-search-function-not-working-as-documented/m-p/1302142#M50184</link>
      <description>&lt;P&gt;Hey there. Unfortunately not&amp;nbsp;&amp;nbsp;&lt;span class="lia-unicode-emoji" title=":frowning_face:"&gt;☹️&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Thankfully in my case, we changed the attendance workflow so generating a dynamic list based on relationship classes was no longer needed. Trying to figure out how to get the search() function working when calling a field so it can be dynamic is still on the list for me to look into further though.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Feel free to copy any of the text or images here if you'd like to start your own post in the forums. Someone out there has to know the solution!&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 22 Jun 2023 17:50:46 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-survey123-questions/help-search-function-not-working-as-documented/m-p/1302142#M50184</guid>
      <dc:creator>Vince_ERAC</dc:creator>
      <dc:date>2023-06-22T17:50:46Z</dc:date>
    </item>
    <item>
      <title>Re: Help! search() function not working as documented</title>
      <link>https://community.esri.com/t5/arcgis-survey123-questions/help-search-function-not-working-as-documented/m-p/1302144#M50185</link>
      <description>&lt;P&gt;Figured it out. If using a GUID, you have to use 'contains' instead of 'matches'.&lt;/P&gt;</description>
      <pubDate>Thu, 22 Jun 2023 17:53:54 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-survey123-questions/help-search-function-not-working-as-documented/m-p/1302144#M50185</guid>
      <dc:creator>JJ_Reyes</dc:creator>
      <dc:date>2023-06-22T17:53:54Z</dc:date>
    </item>
    <item>
      <title>Re: Help! search() function not working as documented</title>
      <link>https://community.esri.com/t5/arcgis-survey123-questions/help-search-function-not-working-as-documented/m-p/1302153#M50186</link>
      <description>&lt;P&gt;Nice! Glad you have it working for you. Did you just use a similar syntax as the following?&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;search('example_search?url=&amp;lt;REST url&amp;gt;/FeatureServer/3', '&lt;EM&gt;&lt;STRONG&gt;contains&lt;/STRONG&gt;&lt;/EM&gt;', 'parentglobalid', '${parentglobalid}')&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;Unfortunately I still can't get it to work on my end. Whether contains or matches is used as the operator, when calling the parentlgobalid dynamically from a field, it still returns every record from that table as opposed to just the records that truly match the parentglobalid.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 22 Jun 2023 18:08:38 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-survey123-questions/help-search-function-not-working-as-documented/m-p/1302153#M50186</guid>
      <dc:creator>Vince_ERAC</dc:creator>
      <dc:date>2023-06-22T18:08:38Z</dc:date>
    </item>
    <item>
      <title>Re: Help! search() function not working as documented</title>
      <link>https://community.esri.com/t5/arcgis-survey123-questions/help-search-function-not-working-as-documented/m-p/1302188#M50191</link>
      <description>&lt;P&gt;Rats! Without the single quotes on the field worked for me:&lt;/P&gt;&lt;P&gt;search('example_search?url=&amp;lt;REST url&amp;gt;/FeatureServer/1','contains','field_guid',${GUID})&lt;/P&gt;</description>
      <pubDate>Thu, 22 Jun 2023 19:12:52 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-survey123-questions/help-search-function-not-working-as-documented/m-p/1302188#M50191</guid>
      <dc:creator>JJ_Reyes</dc:creator>
      <dc:date>2023-06-22T19:12:52Z</dc:date>
    </item>
    <item>
      <title>Re: Help! search() function not working as documented</title>
      <link>https://community.esri.com/t5/arcgis-survey123-questions/help-search-function-not-working-as-documented/m-p/1303006#M50251</link>
      <description>&lt;P&gt;Awesome, glad it's solved on your end.Thanks for sharing what worked for you! I'll keep playing around with the search query and hopefully find something that works. If I find what the issue is, I'll be sure update this thread.&lt;/P&gt;&lt;P&gt;All the best!&lt;/P&gt;</description>
      <pubDate>Mon, 26 Jun 2023 14:41:35 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-survey123-questions/help-search-function-not-working-as-documented/m-p/1303006#M50251</guid>
      <dc:creator>Vince_ERAC</dc:creator>
      <dc:date>2023-06-26T14:41:35Z</dc:date>
    </item>
  </channel>
</rss>

