<?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 Performing Synchronous queries in Flex in ArcGIS API for Flex Questions</title>
    <link>https://community.esri.com/t5/arcgis-api-for-flex-questions/performing-synchronous-queries-in-flex/m-p/8202#M171</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hi all:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I've become so used to asynchronous queries that when I came across a case where I need it to behave synchronously, I don't know what to do!&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;My attempted code is below. The problem is that the code gets to the return function before the embedded onResult function fires.&amp;nbsp; What I want is to query and determine the highest value in a field, then return that value +1.&amp;nbsp; I know I could do this as separate functions, but that becomes really ugly for the rest of my application.&amp;nbsp; I want a single function that is called, waits for an answer, then returns the answer.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;&amp;nbsp;&amp;nbsp; private function getNewProjectQuoteId():int
&amp;nbsp;&amp;nbsp; {
&amp;nbsp;&amp;nbsp;&amp;nbsp; var query:Query = new Query();
&amp;nbsp;&amp;nbsp;&amp;nbsp; query.where = "projectquoteid &amp;gt; 0";
&amp;nbsp;&amp;nbsp;&amp;nbsp; query.outFields = ["projectquoteid"];
&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp; queryProjectQuotesTask.execute(query, new AsyncResponder(onResult, onFault));
&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp; var previousInt:int = -1;
&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp; function onResult(fSet:FeatureSet, token:Object = null):void
&amp;nbsp;&amp;nbsp;&amp;nbsp; {
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; for (var x:int = 0; x &amp;lt; fSet.attributes.length; x++)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if (fSet.attributes&lt;X&gt;.projectquoteid &amp;gt; previousInt)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; previousInt = fSet.attributes&lt;X&gt;.projectquoteid;
&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;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp; function onFault(info:Object, token:Object = null):void
&amp;nbsp;&amp;nbsp;&amp;nbsp; {
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Alert.show(info.toString());
&amp;nbsp;&amp;nbsp;&amp;nbsp; }
&amp;nbsp;&amp;nbsp;&amp;nbsp; return previousInt + 1

&amp;nbsp;&amp;nbsp; }&lt;/X&gt;&lt;/X&gt;&lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 16 Apr 2014 19:17:38 GMT</pubDate>
    <dc:creator>AndrewBlakey</dc:creator>
    <dc:date>2014-04-16T19:17:38Z</dc:date>
    <item>
      <title>Performing Synchronous queries in Flex</title>
      <link>https://community.esri.com/t5/arcgis-api-for-flex-questions/performing-synchronous-queries-in-flex/m-p/8202#M171</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hi all:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I've become so used to asynchronous queries that when I came across a case where I need it to behave synchronously, I don't know what to do!&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;My attempted code is below. The problem is that the code gets to the return function before the embedded onResult function fires.&amp;nbsp; What I want is to query and determine the highest value in a field, then return that value +1.&amp;nbsp; I know I could do this as separate functions, but that becomes really ugly for the rest of my application.&amp;nbsp; I want a single function that is called, waits for an answer, then returns the answer.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;&amp;nbsp;&amp;nbsp; private function getNewProjectQuoteId():int
&amp;nbsp;&amp;nbsp; {
&amp;nbsp;&amp;nbsp;&amp;nbsp; var query:Query = new Query();
&amp;nbsp;&amp;nbsp;&amp;nbsp; query.where = "projectquoteid &amp;gt; 0";
&amp;nbsp;&amp;nbsp;&amp;nbsp; query.outFields = ["projectquoteid"];
&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp; queryProjectQuotesTask.execute(query, new AsyncResponder(onResult, onFault));
&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp; var previousInt:int = -1;
&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp; function onResult(fSet:FeatureSet, token:Object = null):void
&amp;nbsp;&amp;nbsp;&amp;nbsp; {
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; for (var x:int = 0; x &amp;lt; fSet.attributes.length; x++)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if (fSet.attributes&lt;X&gt;.projectquoteid &amp;gt; previousInt)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; previousInt = fSet.attributes&lt;X&gt;.projectquoteid;
&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;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp; function onFault(info:Object, token:Object = null):void
&amp;nbsp;&amp;nbsp;&amp;nbsp; {
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Alert.show(info.toString());
&amp;nbsp;&amp;nbsp;&amp;nbsp; }
&amp;nbsp;&amp;nbsp;&amp;nbsp; return previousInt + 1

&amp;nbsp;&amp;nbsp; }&lt;/X&gt;&lt;/X&gt;&lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 16 Apr 2014 19:17:38 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-flex-questions/performing-synchronous-queries-in-flex/m-p/8202#M171</guid>
      <dc:creator>AndrewBlakey</dc:creator>
      <dc:date>2014-04-16T19:17:38Z</dc:date>
    </item>
  </channel>
</rss>

