<?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 Re: Best practice of using addEncodedQuery in Developer forum</title>
    <link>https://www.servicenow.com/community/developer-forum/best-practice-of-using-addencodedquery/m-p/2459810#M960446</link>
    <description>&lt;P&gt;Try this&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;var test='99894226';
var test1='TESTING';
var fieldMappingRef = new GlideRecord('asset');
fieldMappingRef.addEncodedQuery('asset_tagSTARTSWITH'+test+'^account.nameSTARTSWITH'+test1);
fieldMappingRef.query();
while (fieldMappingRef.next()) {
gs.info("enter"+fieldMappingRef.getUniqueValue());
}&lt;/LI-CODE&gt;</description>
    <pubDate>Fri, 27 Jan 2023 05:00:19 GMT</pubDate>
    <dc:creator>Anup Desai1</dc:creator>
    <dc:date>2023-01-27T05:00:19Z</dc:date>
    <item>
      <title>Best practice of using addEncodedQuery</title>
      <link>https://www.servicenow.com/community/developer-forum/best-practice-of-using-addencodedquery/m-p/2459798#M960438</link>
      <description>&lt;P&gt;Hi Team,&lt;/P&gt;&lt;P&gt;I'm using the below addEncodedQuery but am facing syntax error .Am trying to fetch in wrong way ?&lt;/P&gt;&lt;P&gt;Please guide me&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;var test='99894226';&lt;/P&gt;&lt;P&gt;var test1='TESTING';&lt;/P&gt;&lt;P&gt;var fieldMappingRef = new GlideRecord('asset');&lt;BR /&gt;fieldMappingRef.addEncodedQuery(asset_tagSTARTSWITH+'test'+^account.nameSTARTSWITH+'test1');&lt;/P&gt;&lt;P&gt;fieldMappingRef.query();&lt;/P&gt;&lt;P&gt;while (fieldMappingRef.next()) {&lt;BR /&gt;gs.info("enter"+fieldMappingRef.getUniqueValue());&lt;BR /&gt;}&lt;/P&gt;</description>
      <pubDate>Fri, 27 Jan 2023 04:48:19 GMT</pubDate>
      <guid>https://www.servicenow.com/community/developer-forum/best-practice-of-using-addencodedquery/m-p/2459798#M960438</guid>
      <dc:creator>String</dc:creator>
      <dc:date>2023-01-27T04:48:19Z</dc:date>
    </item>
    <item>
      <title>Re: Best practice of using addEncodedQuery</title>
      <link>https://www.servicenow.com/community/developer-forum/best-practice-of-using-addencodedquery/m-p/2459808#M960444</link>
      <description>&lt;P&gt;Easy way is to set it up in the list view.&amp;nbsp; Right click the query at the top of the list, copy the query.&amp;nbsp; &amp;nbsp;Paste it into your Encoded query.&amp;nbsp; What you have is fine.&amp;nbsp; If you want to do some trickier stuff, look up RLQuery, you can generate this by creating a report and using the SN Utils chrome extension to avoid having to save the report.&lt;/P&gt;</description>
      <pubDate>Fri, 27 Jan 2023 04:54:26 GMT</pubDate>
      <guid>https://www.servicenow.com/community/developer-forum/best-practice-of-using-addencodedquery/m-p/2459808#M960444</guid>
      <dc:creator>Community Alums</dc:creator>
      <dc:date>2023-01-27T04:54:26Z</dc:date>
    </item>
    <item>
      <title>Re: Best practice of using addEncodedQuery</title>
      <link>https://www.servicenow.com/community/developer-forum/best-practice-of-using-addencodedquery/m-p/2459810#M960446</link>
      <description>&lt;P&gt;Try this&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;var test='99894226';
var test1='TESTING';
var fieldMappingRef = new GlideRecord('asset');
fieldMappingRef.addEncodedQuery('asset_tagSTARTSWITH'+test+'^account.nameSTARTSWITH'+test1);
fieldMappingRef.query();
while (fieldMappingRef.next()) {
gs.info("enter"+fieldMappingRef.getUniqueValue());
}&lt;/LI-CODE&gt;</description>
      <pubDate>Fri, 27 Jan 2023 05:00:19 GMT</pubDate>
      <guid>https://www.servicenow.com/community/developer-forum/best-practice-of-using-addencodedquery/m-p/2459810#M960446</guid>
      <dc:creator>Anup Desai1</dc:creator>
      <dc:date>2023-01-27T05:00:19Z</dc:date>
    </item>
    <item>
      <title>Re: Best practice of using addEncodedQuery</title>
      <link>https://www.servicenow.com/community/developer-forum/best-practice-of-using-addencodedquery/m-p/2459814#M960449</link>
      <description>&lt;P&gt;&lt;SPAN&gt;addEncodedQuery accepts string as parameter. So in your query, you need to enclose it in ' ' and it would look like this&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;'asset_tagSTARTSWITH' + test + '^account.nameSTARTSWITH' + test1.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Your original query treats&amp;nbsp;asset_tagSTARTSWITH as a variable name instead of a string. hope this helps.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 27 Jan 2023 05:02:23 GMT</pubDate>
      <guid>https://www.servicenow.com/community/developer-forum/best-practice-of-using-addencodedquery/m-p/2459814#M960449</guid>
      <dc:creator>GeraldKirby</dc:creator>
      <dc:date>2023-01-27T05:02:23Z</dc:date>
    </item>
  </channel>
</rss>

