<?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>question Reference qualifier for list collector via script include does not work in Developer forum</title>
    <link>https://www.servicenow.com/community/developer-forum/reference-qualifier-for-list-collector-via-script-include-does/m-p/1468307#M125233</link>
    <description>&lt;P class="ng-scope"&gt;Hi All,&lt;/P&gt;
&lt;P class="ng-scope"&gt;I am looking for help in identifying any issue with the following piece of Script Include code. I have two variable in 'Select location' (references to cmn_location table) and 'Select equipments' (Type-List collector (u_location_equipments)).&lt;/P&gt;
&lt;P class="ng-scope"&gt;I have requirement to create reference qualifier on 'select equipments' variable based on 'select location'.For ex. If location is AC - FF – 001 then it should show only Projector, Video Conferencing Solution (WebEX), Table MIC.&lt;/P&gt;
&lt;P class="ng-scope"&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="find_real_file.png"&gt;&lt;img src="https://www.servicenow.com/community/image/serverpage/image-id/166400iF873FFC59073F41E/image-size/large?v=v2&amp;amp;px=999" role="button" title="find_real_file.png" alt="find_real_file.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P class="ng-scope"&gt;I'm using below script include but it is not working,&lt;/P&gt;
&lt;P class="ng-scope"&gt;----------------------------------------------------------------------------&lt;/P&gt;
&lt;P&gt;var GetEquipments = Class.create();&lt;BR /&gt;GetEquipments.prototype = Object.extendsObject(AbstractAjaxProcessor, {&lt;BR /&gt; &lt;BR /&gt;allEquipments:function(){&lt;BR /&gt; &lt;BR /&gt; var include = '';&lt;BR /&gt; var selectedLoc = current.variables.select_location;&lt;BR /&gt; &lt;BR /&gt; var equ = new GlideRecord('u_location_equipments');&lt;BR /&gt; equ.addQuery('u_location', selectedLoc);&lt;BR /&gt; equ.query();&lt;/P&gt;
&lt;P&gt;while(users2.next()) &lt;BR /&gt; {&lt;BR /&gt; include += (',' + equ.u_equipment);&lt;BR /&gt; }&lt;BR /&gt; &lt;BR /&gt; //return criteria string&lt;BR /&gt; return 'sys_id IN' + include;&lt;BR /&gt; }, &lt;BR /&gt; &lt;BR /&gt; type: 'GetEquipments'&lt;BR /&gt;});&lt;/P&gt;
&lt;P&gt;-----------------------------------------------------------------&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P class="ng-scope"&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="find_real_file.png"&gt;&lt;img src="https://www.servicenow.com/community/image/serverpage/image-id/166404iEE081143B5B58005/image-size/large?v=v2&amp;amp;px=999" role="button" title="find_real_file.png" alt="find_real_file.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P class="ng-scope"&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 30 Jul 2019 06:24:26 GMT</pubDate>
    <dc:creator>Payal5</dc:creator>
    <dc:date>2019-07-30T06:24:26Z</dc:date>
    <item>
      <title>Reference qualifier for list collector via script include does not work</title>
      <link>https://www.servicenow.com/community/developer-forum/reference-qualifier-for-list-collector-via-script-include-does/m-p/1468307#M125233</link>
      <description>&lt;P class="ng-scope"&gt;Hi All,&lt;/P&gt;
&lt;P class="ng-scope"&gt;I am looking for help in identifying any issue with the following piece of Script Include code. I have two variable in 'Select location' (references to cmn_location table) and 'Select equipments' (Type-List collector (u_location_equipments)).&lt;/P&gt;
&lt;P class="ng-scope"&gt;I have requirement to create reference qualifier on 'select equipments' variable based on 'select location'.For ex. If location is AC - FF – 001 then it should show only Projector, Video Conferencing Solution (WebEX), Table MIC.&lt;/P&gt;
&lt;P class="ng-scope"&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="find_real_file.png"&gt;&lt;img src="https://www.servicenow.com/community/image/serverpage/image-id/166400iF873FFC59073F41E/image-size/large?v=v2&amp;amp;px=999" role="button" title="find_real_file.png" alt="find_real_file.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P class="ng-scope"&gt;I'm using below script include but it is not working,&lt;/P&gt;
&lt;P class="ng-scope"&gt;----------------------------------------------------------------------------&lt;/P&gt;
&lt;P&gt;var GetEquipments = Class.create();&lt;BR /&gt;GetEquipments.prototype = Object.extendsObject(AbstractAjaxProcessor, {&lt;BR /&gt; &lt;BR /&gt;allEquipments:function(){&lt;BR /&gt; &lt;BR /&gt; var include = '';&lt;BR /&gt; var selectedLoc = current.variables.select_location;&lt;BR /&gt; &lt;BR /&gt; var equ = new GlideRecord('u_location_equipments');&lt;BR /&gt; equ.addQuery('u_location', selectedLoc);&lt;BR /&gt; equ.query();&lt;/P&gt;
&lt;P&gt;while(users2.next()) &lt;BR /&gt; {&lt;BR /&gt; include += (',' + equ.u_equipment);&lt;BR /&gt; }&lt;BR /&gt; &lt;BR /&gt; //return criteria string&lt;BR /&gt; return 'sys_id IN' + include;&lt;BR /&gt; }, &lt;BR /&gt; &lt;BR /&gt; type: 'GetEquipments'&lt;BR /&gt;});&lt;/P&gt;
&lt;P&gt;-----------------------------------------------------------------&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P class="ng-scope"&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="find_real_file.png"&gt;&lt;img src="https://www.servicenow.com/community/image/serverpage/image-id/166404iEE081143B5B58005/image-size/large?v=v2&amp;amp;px=999" role="button" title="find_real_file.png" alt="find_real_file.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P class="ng-scope"&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 30 Jul 2019 06:24:26 GMT</pubDate>
      <guid>https://www.servicenow.com/community/developer-forum/reference-qualifier-for-list-collector-via-script-include-does/m-p/1468307#M125233</guid>
      <dc:creator>Payal5</dc:creator>
      <dc:date>2019-07-30T06:24:26Z</dc:date>
    </item>
    <item>
      <title>Re: Reference qualifier for list collector via script include does not work</title>
      <link>https://www.servicenow.com/community/developer-forum/reference-qualifier-for-list-collector-via-script-include-does/m-p/1468308#M125234</link>
      <description>&lt;P&gt;I have found three bugs:&lt;/P&gt;
&lt;OL&gt;&lt;LI&gt;Incorrect variable name in while loop&lt;/LI&gt;&lt;LI&gt;Dot-walking in a while loop&lt;/LI&gt;&lt;LI&gt;space in encoded query&lt;/LI&gt;&lt;/OL&gt;
&lt;P&gt;I've also modified your code to use an array instead, as it is a bit tidier.&lt;/P&gt;
&lt;PRE class="language-javascript"&gt;&lt;CODE&gt;var GetEquipments = Class.create();
GetEquipments.prototype = Object.extendsObject(AbstractAjaxProcessor, {

allEquipments:function(){
//var include = '';
var include = [];  // Use array, push() &amp;amp; join(",") instead
var selectedLoc = current.variables.select_location;

var equ = new GlideRecord('u_location_equipments');
equ.addQuery('u_location', selectedLoc);
equ.query();

// while(users2.next())   Bug #1 - wrong variable name
while(equ.next()) // replaced with equ
{
//include += (',' + equ.u_equipment); Bug #2 - dot walking in while loop
include.push(equ.getValue('u_equipment')); // use getValue instead 
}

//return criteria string
//return 'sys_id IN' + include; Bug #3 - Erronerous space here
return 'sys_idIN' + include.join(","); // removed space
}, 

type: 'GetEquipments'
});&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 30 Jul 2019 06:34:22 GMT</pubDate>
      <guid>https://www.servicenow.com/community/developer-forum/reference-qualifier-for-list-collector-via-script-include-does/m-p/1468308#M125234</guid>
      <dc:creator>paulmorris</dc:creator>
      <dc:date>2019-07-30T06:34:22Z</dc:date>
    </item>
    <item>
      <title>Re: Reference qualifier for list collector via script include does not work</title>
      <link>https://www.servicenow.com/community/developer-forum/reference-qualifier-for-list-collector-via-script-include-does/m-p/1468309#M125235</link>
      <description>&lt;P&gt;Hi Paul,&lt;/P&gt;
&lt;P&gt;Thanks for the reply.&lt;/P&gt;
&lt;P&gt;I updated the code but it is returning "No Matches found" when i&amp;nbsp;set location as&amp;nbsp;AC - FF – 001&lt;/P&gt;</description>
      <pubDate>Tue, 30 Jul 2019 06:45:12 GMT</pubDate>
      <guid>https://www.servicenow.com/community/developer-forum/reference-qualifier-for-list-collector-via-script-include-does/m-p/1468309#M125235</guid>
      <dc:creator>Payal5</dc:creator>
      <dc:date>2019-07-30T06:45:12Z</dc:date>
    </item>
    <item>
      <title>Re: Reference qualifier for list collector via script include does not work</title>
      <link>https://www.servicenow.com/community/developer-forum/reference-qualifier-for-list-collector-via-script-include-does/m-p/1468310#M125236</link>
      <description>&lt;P&gt;Hello Payal,&lt;/P&gt;
&lt;P&gt;Just small change in code.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;var GetEquipments = Class.create();&lt;BR /&gt;GetEquipments.prototype = Object.extendsObject(AbstractAjaxProcessor, {&lt;/P&gt;
&lt;P&gt;allEquipments:function(){&lt;BR /&gt;//var include = '';&lt;BR /&gt;var include = []; // Use array, push() &amp;amp; join(",") instead&lt;BR /&gt;var selectedLoc = current.variables.select_location;&lt;/P&gt;
&lt;P&gt;var equ = new GlideRecord('u_location_equipments');&lt;BR /&gt;equ.addQuery('u_location', selectedLoc);&lt;BR /&gt;equ.query();&lt;/P&gt;
&lt;P&gt;// while(users2.next()) Bug #1 - wrong variable name&lt;BR /&gt;while(equ.next()) // replaced with equ&lt;BR /&gt;{&lt;BR /&gt;//include += (',' + equ.u_equipment); Bug #2 - dot walking in while loop&lt;BR /&gt;&lt;STRONG&gt;include.push(equ.getValue('u_equipment').toString());&lt;/STRONG&gt; // use getValue instead &lt;BR /&gt;}&lt;/P&gt;
&lt;P&gt;//return criteria string&lt;BR /&gt;return 'sys_id IN' + include; Bug&lt;BR /&gt;},&lt;/P&gt;
&lt;P&gt;type: 'GetEquipments'&lt;BR /&gt;});&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Also try adding logs to check that you are getting the correct values in array and getrowcount as well&lt;/P&gt;
&lt;P&gt;Please mark as Correct Answer/Helpful, if applicable.&lt;BR /&gt;Thanks! &lt;BR /&gt;Abhishek Gardade&lt;/P&gt;</description>
      <pubDate>Tue, 30 Jul 2019 07:37:32 GMT</pubDate>
      <guid>https://www.servicenow.com/community/developer-forum/reference-qualifier-for-list-collector-via-script-include-does/m-p/1468310#M125236</guid>
      <dc:creator>AbhishekGardade</dc:creator>
      <dc:date>2019-07-30T07:37:32Z</dc:date>
    </item>
    <item>
      <title>Re: Reference qualifier for list collector via script include does not work</title>
      <link>https://www.servicenow.com/community/developer-forum/reference-qualifier-for-list-collector-via-script-include-does/m-p/1468311#M125237</link>
      <description>&lt;P&gt;Hi Payal,&lt;/P&gt;
&lt;P&gt;Hope below code helps you!!!&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;Script Include :&lt;/STRONG&gt;&lt;BR /&gt;Name : GetEquipments&lt;BR /&gt;API Name : global.GetEquipments&lt;/P&gt;
&lt;P&gt;--------------------------------------------------------------------&lt;BR /&gt;function GetEquipments(){&lt;BR /&gt; var array = [];&lt;BR /&gt; var location = current.variables.select_location; &lt;BR /&gt; &lt;BR /&gt; var gloc = new GlideRecord('u_location_equipments');&lt;BR /&gt; gloc.addEncodedQuery('u_location='+location); &lt;BR /&gt; //gs.addInfoMessage(gloc.getEncodedQuery());&lt;BR /&gt; gloc.query();&lt;BR /&gt; while(gloc.next())&lt;BR /&gt; {&lt;BR /&gt; array.push(gloc.getValue("u_equipment"));&lt;BR /&gt; &lt;BR /&gt; }&lt;BR /&gt; gs.addInfoMessage(array.toString());&lt;BR /&gt; return 'sys_idIN' +array;&lt;BR /&gt;}&lt;/P&gt;
&lt;P&gt;--------------------------------------------------------------------&lt;BR /&gt;&lt;STRONG&gt;Add Reference Qualifier on the variable "select_location" :&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;javascript:global.GetEquipments();&lt;/P&gt;
&lt;P&gt;--------------------------------------------------------------------&lt;/P&gt;
&lt;P&gt;Regards,&lt;BR /&gt;Sanket&lt;/P&gt;</description>
      <pubDate>Tue, 30 Jul 2019 07:46:35 GMT</pubDate>
      <guid>https://www.servicenow.com/community/developer-forum/reference-qualifier-for-list-collector-via-script-include-does/m-p/1468311#M125237</guid>
      <dc:creator>Sanket Khabiya</dc:creator>
      <dc:date>2019-07-30T07:46:35Z</dc:date>
    </item>
    <item>
      <title>Re: Reference qualifier for list collector via script include does not work</title>
      <link>https://www.servicenow.com/community/developer-forum/reference-qualifier-for-list-collector-via-script-include-does/m-p/1468312#M125238</link>
      <description>&lt;P&gt;Replace this line&lt;/P&gt;
&lt;PRE class="language-javascript"&gt;&lt;CODE&gt;include.push(equ.getValue('u_equipment')); // use getValue instead &lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;with this line&lt;/P&gt;
&lt;PRE class="language-javascript"&gt;&lt;CODE&gt;include.push(equ.getValue('sys_id')); // use getValue instead &lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 30 Jul 2019 08:26:51 GMT</pubDate>
      <guid>https://www.servicenow.com/community/developer-forum/reference-qualifier-for-list-collector-via-script-include-does/m-p/1468312#M125238</guid>
      <dc:creator>paulmorris</dc:creator>
      <dc:date>2019-07-30T08:26:51Z</dc:date>
    </item>
    <item>
      <title>Re: Reference qualifier for list collector via script include does not work</title>
      <link>https://www.servicenow.com/community/developer-forum/reference-qualifier-for-list-collector-via-script-include-does/m-p/1468313#M125239</link>
      <description>&lt;P&gt;I tried it but still giving No "Matches Found"&lt;/P&gt;</description>
      <pubDate>Tue, 30 Jul 2019 08:44:25 GMT</pubDate>
      <guid>https://www.servicenow.com/community/developer-forum/reference-qualifier-for-list-collector-via-script-include-does/m-p/1468313#M125239</guid>
      <dc:creator>Payal5</dc:creator>
      <dc:date>2019-07-30T08:44:25Z</dc:date>
    </item>
    <item>
      <title>Re: Reference qualifier for list collector via script include does not work</title>
      <link>https://www.servicenow.com/community/developer-forum/reference-qualifier-for-list-collector-via-script-include-does/m-p/1468314#M125240</link>
      <description>&lt;P&gt;Can you share a complete screenshot of the script include?&lt;/P&gt;
&lt;P&gt;Thanks,&lt;BR /&gt;Abhishek&lt;/P&gt;</description>
      <pubDate>Tue, 30 Jul 2019 09:14:27 GMT</pubDate>
      <guid>https://www.servicenow.com/community/developer-forum/reference-qualifier-for-list-collector-via-script-include-does/m-p/1468314#M125240</guid>
      <dc:creator>AbhishekGardade</dc:creator>
      <dc:date>2019-07-30T09:14:27Z</dc:date>
    </item>
    <item>
      <title>Re: Reference qualifier for list collector via script include does not work</title>
      <link>https://www.servicenow.com/community/developer-forum/reference-qualifier-for-list-collector-via-script-include-does/m-p/1468315#M125241</link>
      <description>&lt;P&gt;Resolved. Just need to write below line in "Select Equipments" reference qualifier,&lt;/P&gt;
&lt;P&gt;javascript:'u_location='+current.variables.select_location&lt;/P&gt;</description>
      <pubDate>Tue, 30 Jul 2019 09:15:14 GMT</pubDate>
      <guid>https://www.servicenow.com/community/developer-forum/reference-qualifier-for-list-collector-via-script-include-does/m-p/1468315#M125241</guid>
      <dc:creator>Payal5</dc:creator>
      <dc:date>2019-07-30T09:15:14Z</dc:date>
    </item>
    <item>
      <title>Re: Reference qualifier for list collector via script include does not work</title>
      <link>https://www.servicenow.com/community/developer-forum/reference-qualifier-for-list-collector-via-script-include-does/m-p/1468316#M125242</link>
      <description>&lt;P&gt;If I have answered your question, please mark my response as correct so that others with the same question in the future can find it quickly and that it gets removed from the Unanswered list.&lt;BR /&gt;Thank you,Abhishek&lt;/P&gt;</description>
      <pubDate>Tue, 30 Jul 2019 09:17:39 GMT</pubDate>
      <guid>https://www.servicenow.com/community/developer-forum/reference-qualifier-for-list-collector-via-script-include-does/m-p/1468316#M125242</guid>
      <dc:creator>AbhishekGardade</dc:creator>
      <dc:date>2019-07-30T09:17:39Z</dc:date>
    </item>
  </channel>
</rss>

