<?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: Modifying the Query Widget in Web AppBuilder Custom Widgets Questions</title>
    <link>https://community.esri.com/t5/web-appbuilder-custom-widgets-questions/modifying-the-query-widget/m-p/799929#M5092</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Yep&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 06 Apr 2015 17:11:38 GMT</pubDate>
    <dc:creator>RobertScheitlin__GISP</dc:creator>
    <dc:date>2015-04-06T17:11:38Z</dc:date>
    <item>
      <title>Modifying the Query Widget</title>
      <link>https://community.esri.com/t5/web-appbuilder-custom-widgets-questions/modifying-the-query-widget/m-p/799922#M5085</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;So I found the Query Widget to be useful, well about 75% useful.&amp;nbsp; So, while the widget functions correctly and works well the results are unable to be sorted.&amp;nbsp; This makes it difficult identifying the result that I want.&amp;nbsp; The main problem that I see with this is that it uses the objectID to sort the results (confirmed by esri tech support).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thankfully they got me on the right track in coding the tool to be sorted.&amp;nbsp; We found that this code queryParams.orderByFields = ["FIELD_NAME"];&lt;/P&gt;&lt;P&gt;placed after line 828 directly following this code, queryParams.objectIds = objectIds; correctly sorted my first query in the widget.&amp;nbsp; However it failed when a second was added.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The tech supports advice was to add an if statements using the url / ID to differentiate the queries and sort each one accordingly.&amp;nbsp; So I found the following code around line 416 - 419 that parsed out the id number from the url.&lt;/P&gt;&lt;P&gt;------------------------&lt;/P&gt;&lt;P&gt;_getLayerIndexByLayerUrl: function(layerUrl){&lt;/P&gt;&lt;P&gt;var lastIndex = layerUrl.lastIndexOf("/");&lt;/P&gt;&lt;P&gt;var a = layerUrl.slice(lastIndex + 1, layerUrl.length);&lt;/P&gt;&lt;P&gt;return parseInt(a, 10);&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I used the variable parseInt in an if statement (below) and it correctly sorted the corresponding search, but failed on the others (obviously), and also killed all of the click functions.&lt;/P&gt;&lt;P&gt;--------------------&lt;/P&gt;&lt;P&gt;if (parseInt = 18)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; queryParams.orderByFields = ["NAME"];&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;As I see it now I have 2 options...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;OL&gt;&lt;LI&gt;Correct the if statement to work correctly...but what am I missing?&lt;/LI&gt;&lt;LI&gt;Build multiple queries into a group widget... I think this is possible right?&lt;/LI&gt;&lt;/OL&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I don't like option 2 as much even though, if possible, it would be easiest.&amp;nbsp; I would be able to hard code the sort field per query and all would be good.&amp;nbsp; However, the current Query widget lends itself well to having multiple queries in the single widget.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thoughts????&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;A href="https://community.esri.com/migrated-users/3101"&gt;Robert Scheitlin, GISP&lt;/A&gt;​&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 01 Apr 2015 19:44:10 GMT</pubDate>
      <guid>https://community.esri.com/t5/web-appbuilder-custom-widgets-questions/modifying-the-query-widget/m-p/799922#M5085</guid>
      <dc:creator>NicholasBarger</dc:creator>
      <dc:date>2015-04-01T19:44:10Z</dc:date>
    </item>
    <item>
      <title>Re: Modifying the Query Widget</title>
      <link>https://community.esri.com/t5/web-appbuilder-custom-widgets-questions/modifying-the-query-widget/m-p/799923#M5086</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Nick,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; Your problem is likely this line if (parseInt = 18)&lt;/P&gt;&lt;P&gt;In JavaScript a single equal sign is an assignment and not a comparison operator.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So it should be if (parseInt === 18)&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 06 Apr 2015 12:49:50 GMT</pubDate>
      <guid>https://community.esri.com/t5/web-appbuilder-custom-widgets-questions/modifying-the-query-widget/m-p/799923#M5086</guid>
      <dc:creator>RobertScheitlin__GISP</dc:creator>
      <dc:date>2015-04-06T12:49:50Z</dc:date>
    </item>
    <item>
      <title>Re: Modifying the Query Widget</title>
      <link>https://community.esri.com/t5/web-appbuilder-custom-widgets-questions/modifying-the-query-widget/m-p/799924#M5087</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I have corrected that line, but I think I need to add more logic to the if statement.&amp;nbsp; It still won't sort correctly.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 06 Apr 2015 15:12:12 GMT</pubDate>
      <guid>https://community.esri.com/t5/web-appbuilder-custom-widgets-questions/modifying-the-query-widget/m-p/799924#M5087</guid>
      <dc:creator>NicholasBarger</dc:creator>
      <dc:date>2015-04-06T15:12:12Z</dc:date>
    </item>
    <item>
      <title>Re: Modifying the Query Widget</title>
      <link>https://community.esri.com/t5/web-appbuilder-custom-widgets-questions/modifying-the-query-widget/m-p/799925#M5088</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Nick,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I guess I would need to see more of what you have done in the _queryByObjectIds function&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 06 Apr 2015 15:31:02 GMT</pubDate>
      <guid>https://community.esri.com/t5/web-appbuilder-custom-widgets-questions/modifying-the-query-widget/m-p/799925#M5088</guid>
      <dc:creator>RobertScheitlin__GISP</dc:creator>
      <dc:date>2015-04-06T15:31:02Z</dc:date>
    </item>
    <item>
      <title>Re: Modifying the Query Widget</title>
      <link>https://community.esri.com/t5/web-appbuilder-custom-widgets-questions/modifying-the-query-widget/m-p/799926#M5089</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Not too much in that section.  ESRI Tech support gave me the query.orderByFields property and together we were able to enter the following statement….&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;queryParams.orderByFields = ["STATION"]&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;this worked fine for my first query (Firestations), but when I added another query that did not contain the STATION field it failed.  ESRI Tech support said there would need to be an if statement and possibly some additional logic in the statement to get the query widget to sort based on the id of the service.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I found the section of code (I think), and the variable that should contain the service id number (parseInt).  Here is the If statement that I have with your previously mentioned changes...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;if (parseInt === 15)&lt;/P&gt;&lt;P&gt;{&lt;/P&gt;&lt;P&gt;  queryParams.orderByFields = ["STATION"];&lt;/P&gt;&lt;P&gt;}&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;When I had the parseInt = 15 it correctly sorted the field (I’m thinking this is because the logic wasn’t correct and it passed to the next line of code).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;When I changed it to your suggestion it worked…but did not sort correctly.  My end goal is to say If the service ID = ## then sort by , else if ID = ## and so on…&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Here is the complete section of code that you are referring to…&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;_queryByObjectIds: function(objectIds, returnGeometry){&lt;/P&gt;&lt;P&gt;        var queryParams = new EsriQuery();&lt;/P&gt;&lt;P&gt;        queryParams.returnGeometry = !!returnGeometry;&lt;/P&gt;&lt;P&gt;        queryParams.outSpatialReference = this.map.spatialReference;&lt;/P&gt;&lt;P&gt;        queryParams.outFields = this._getOutputFields();&lt;/P&gt;&lt;P&gt;        queryParams.objectIds = objectIds;&lt;/P&gt;&lt;P&gt;                                //if (parseInt === 15)&lt;/P&gt;&lt;P&gt;                                //            {&lt;/P&gt;&lt;P&gt;                                //               queryParams.orderByFields = ["STATION"];&lt;/P&gt;&lt;P&gt;                                //            }&lt;/P&gt;&lt;P&gt;        var queryTask = new QueryTask(this.currentAttrs.config.url);&lt;/P&gt;&lt;P&gt;        return queryTask.execute(queryParams);&lt;/P&gt;&lt;P&gt;      },&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have commented out the section with the if statement so that the app works correctly.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;~ Nick&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 06 Apr 2015 16:32:39 GMT</pubDate>
      <guid>https://community.esri.com/t5/web-appbuilder-custom-widgets-questions/modifying-the-query-widget/m-p/799926#M5089</guid>
      <dc:creator>NicholasBarger</dc:creator>
      <dc:date>2015-04-06T16:32:39Z</dc:date>
    </item>
    <item>
      <title>Re: Modifying the Query Widget</title>
      <link>https://community.esri.com/t5/web-appbuilder-custom-widgets-questions/modifying-the-query-widget/m-p/799927#M5090</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Nick,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; OK now that makes sence as to what you are doing wrong. the _queryByObjectIds function is looking at your&amp;nbsp; parseInt line and parseInt is a function in JS and not normally a variable unless you declare it to be. So your code makes no sense. Try this:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; _queryByObjectIds: function(objectIds, returnGeometry){
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; var queryParams = new EsriQuery();
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; queryParams.returnGeometry = !!returnGeometry;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; queryParams.outSpatialReference = this.map.spatialReference;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; queryParams.outFields = this._getOutputFields();
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; queryParams.objectIds = objectIds;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; var layerId = this._getLayerIndexByLayerUrl(this.currentAttrs.config.url);
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if (layerId === 18){
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; queryParams.orderByFields = ["NAME"];
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; var queryTask = new QueryTask(this.currentAttrs.config.url);
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; return queryTask.execute(queryParams);
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; },&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 09:15:46 GMT</pubDate>
      <guid>https://community.esri.com/t5/web-appbuilder-custom-widgets-questions/modifying-the-query-widget/m-p/799927#M5090</guid>
      <dc:creator>RobertScheitlin__GISP</dc:creator>
      <dc:date>2021-12-12T09:15:46Z</dc:date>
    </item>
    <item>
      <title>Re: Modifying the Query Widget</title>
      <link>https://community.esri.com/t5/web-appbuilder-custom-widgets-questions/modifying-the-query-widget/m-p/799928#M5091</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;That was the trick.&amp;nbsp; I had tried a variation of declaring the variable but I failed to include the additional code after the var layerid.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;At this point I should be able to nest the if statement to include the other layers that I am looking to sort right?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 06 Apr 2015 16:57:14 GMT</pubDate>
      <guid>https://community.esri.com/t5/web-appbuilder-custom-widgets-questions/modifying-the-query-widget/m-p/799928#M5091</guid>
      <dc:creator>NicholasBarger</dc:creator>
      <dc:date>2015-04-06T16:57:14Z</dc:date>
    </item>
    <item>
      <title>Re: Modifying the Query Widget</title>
      <link>https://community.esri.com/t5/web-appbuilder-custom-widgets-questions/modifying-the-query-widget/m-p/799929#M5092</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Yep&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 06 Apr 2015 17:11:38 GMT</pubDate>
      <guid>https://community.esri.com/t5/web-appbuilder-custom-widgets-questions/modifying-the-query-widget/m-p/799929#M5092</guid>
      <dc:creator>RobertScheitlin__GISP</dc:creator>
      <dc:date>2015-04-06T17:11:38Z</dc:date>
    </item>
    <item>
      <title>Re: Modifying the Query Widget</title>
      <link>https://community.esri.com/t5/web-appbuilder-custom-widgets-questions/modifying-the-query-widget/m-p/799930#M5093</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Worked!!!&amp;nbsp; Easy fix...thanks Robert!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 06 Apr 2015 18:55:21 GMT</pubDate>
      <guid>https://community.esri.com/t5/web-appbuilder-custom-widgets-questions/modifying-the-query-widget/m-p/799930#M5093</guid>
      <dc:creator>NicholasBarger</dc:creator>
      <dc:date>2015-04-06T18:55:21Z</dc:date>
    </item>
    <item>
      <title>Re: Modifying the Query Widget</title>
      <link>https://community.esri.com/t5/web-appbuilder-custom-widgets-questions/modifying-the-query-widget/m-p/799931#M5094</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Wawooo ,,, This look like a puzzle. I hope you will figure it out... staay in touch with the support team the can help.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 07 Apr 2015 03:36:14 GMT</pubDate>
      <guid>https://community.esri.com/t5/web-appbuilder-custom-widgets-questions/modifying-the-query-widget/m-p/799931#M5094</guid>
      <dc:creator>GloriaTshokama</dc:creator>
      <dc:date>2015-04-07T03:36:14Z</dc:date>
    </item>
  </channel>
</rss>

