<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0">
<channel>
<title>Efficy Overflow Q&amp;A - Recent questions tagged consultquery</title>
<link>https://overflow.efficy.io/?qa=tag/consultquery</link>
<description>Powered by Question2Answer</description>
<item>
<title>ConsultQuery on list SYS_QUERIES not working</title>
<link>https://overflow.efficy.io/?qa=3231/consultquery-on-list-sysqueries-not-working</link>
<description>&lt;p&gt;Dear All,&lt;/p&gt;

&lt;p&gt;I am trying to get the list of opportunity (keys) depending of the filters the user set up.&lt;br&gt;
In order to do that I am trying to use the consultQuery function describe in EDN : &lt;a rel=&quot;nofollow&quot; href=&quot;https://help.efficy.com/edn/serverjs&quot;&gt;&lt;/a&gt;&lt;a rel=&quot;nofollow&quot; href=&quot;https://help.efficy.com/edn/serverjs&quot;&gt;https://help.efficy.com/edn/serverjs&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;I have create the following code, but the dataset is always empty, what did I do wrong ?&lt;/p&gt;

&lt;p&gt;serverscript file : test.js&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;  function test() {
    var queryHandle;
    var contextHandle = Database.openTemporaryContext();
    var params = VarArrayOf(['1', Database.currentUserId()]);
    var sourceDs = Database.consultQuery(queryHandle, contextHandle, 22, 0, params, true, true, '');

    sourceDs.Filtered = false
    sourceDs.Last
    sourceDs.First

    var result='&amp;lt;br&amp;gt;Oppo list: (';
    while (!sourceDs.Eof) {
        result += sourceDs.FieldByName('K_OPPORTUNITY').AsString + ', ';
        sourceDs.Next();
    }
    result += ')';
    return result;
}
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Macro file : MacroListCustom.txt &lt;/p&gt;

&lt;pre&gt;&lt;code&gt;ListGrid.Oppo {[
&amp;lt;%LoadScript(test)%&amp;gt;
Launching Serverscript test....
&amp;lt;%RunScript(test)%&amp;gt;
&amp;lt;%Macro(&quot;ListGridTemplate&quot;, $COLUMNS$=&quot;MENU,NAME,R_MANAGER,D_TARGET,D_USED,R_STATUS,CONTACT,COMPANY,SUCCESS{NUMERIC},ADJBUDGET{NUMERIC}&quot;, $SUM$=&quot;ADJBUDGET&quot;)%&amp;gt;
]}
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;And when adding the Parameters, it seems the Key of the current user does not change in the ConsultQuery Call&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;https://overflow.efficy.com/?qa=blob&amp;amp;qa_blobid=17845584832708201463&quot; alt=&quot;ConsultQuery comparison with List query&quot;&gt;&lt;/p&gt;

&lt;p&gt;Remark : the sys&lt;em&gt;query : K&lt;/em&gt;MASTER = 22 and K_DETAIL = 0 is the standard Efficy one&lt;/p&gt;

&lt;p&gt;Best Regards,&lt;br&gt;
Stéphane R.&lt;/p&gt;
</description>
<category>WorkFlow / Serverscript</category>
<guid isPermaLink="true">https://overflow.efficy.io/?qa=3231/consultquery-on-list-sysqueries-not-working</guid>
<pubDate>Fri, 08 Jun 2018 06:25:02 +0000</pubDate>
</item>
</channel>
</rss>