<?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 How to Query Reference field using script in Developer forum</title>
    <link>https://www.servicenow.com/community/developer-forum/how-to-query-reference-field-using-script/m-p/1875426#M532352</link>
    <description>&lt;P&gt;In catalog item, i have variable"location" as type "Reference " to location table (cmn_location),In that variable "location" it need to Hide some locations while searching on magnifying search of that Variable specific to this catalog item .&lt;/P&gt;
&lt;P&gt;The variable "location" is in variable set &amp;amp; using in multiple catalog items, i cannot use Reference qualifier in this case as the requirement is specific to one catalog item.&lt;/P&gt;
&lt;P&gt;how can achieve this by scripting?&lt;/P&gt;</description>
    <pubDate>Tue, 20 Sep 2022 11:30:36 GMT</pubDate>
    <dc:creator>Sudesh</dc:creator>
    <dc:date>2022-09-20T11:30:36Z</dc:date>
    <item>
      <title>How to Query Reference field using script</title>
      <link>https://www.servicenow.com/community/developer-forum/how-to-query-reference-field-using-script/m-p/1875426#M532352</link>
      <description>&lt;P&gt;In catalog item, i have variable"location" as type "Reference " to location table (cmn_location),In that variable "location" it need to Hide some locations while searching on magnifying search of that Variable specific to this catalog item .&lt;/P&gt;
&lt;P&gt;The variable "location" is in variable set &amp;amp; using in multiple catalog items, i cannot use Reference qualifier in this case as the requirement is specific to one catalog item.&lt;/P&gt;
&lt;P&gt;how can achieve this by scripting?&lt;/P&gt;</description>
      <pubDate>Tue, 20 Sep 2022 11:30:36 GMT</pubDate>
      <guid>https://www.servicenow.com/community/developer-forum/how-to-query-reference-field-using-script/m-p/1875426#M532352</guid>
      <dc:creator>Sudesh</dc:creator>
      <dc:date>2022-09-20T11:30:36Z</dc:date>
    </item>
    <item>
      <title>Re: How to Query Reference field using script</title>
      <link>https://www.servicenow.com/community/developer-forum/how-to-query-reference-field-using-script/m-p/1875427#M532353</link>
      <description>&lt;P&gt;Hello Sudesh,&lt;/P&gt;
&lt;P&gt;You can create a new variable in your variable set for example &lt;EM&gt;&lt;STRONG&gt;catalog_item_id&lt;/STRONG&gt;&lt;/EM&gt; and then use the onLoad client script on your variable set to set the catalog ID in this variable:&lt;/P&gt;
&lt;PRE class="language-javascript"&gt;&lt;CODE&gt;g_form.setValue("catalog_item_id", g_form.getParameter("sys_id"));&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;then in your reference qualifier you can pass the catalog Item ID&lt;/P&gt;
&lt;PRE class="language-javascript"&gt;&lt;CODE&gt;javascript:new your_script_include_name().function_name(current.variables.catalog_item_id);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;and in your script include then you can apply query based on the catalog item id and return the result. So in future if you receive a similar requirement for other catalog Item you can just update the query or script in your script include to return the data accordingly.&lt;/P&gt;
&lt;P&gt;&lt;EM&gt;&lt;STRONG&gt;If my answer helped you in any way then please do mark it as helpful. If it answered your question then please mark it correct and helpful.&amp;nbsp;&lt;/STRONG&gt;&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;Thanks&lt;/P&gt;</description>
      <pubDate>Wed, 21 Sep 2022 11:56:01 GMT</pubDate>
      <guid>https://www.servicenow.com/community/developer-forum/how-to-query-reference-field-using-script/m-p/1875427#M532353</guid>
      <dc:creator>Mahendra RC</dc:creator>
      <dc:date>2022-09-21T11:56:01Z</dc:date>
    </item>
    <item>
      <title>Re: How to Query Reference field using script</title>
      <link>https://www.servicenow.com/community/developer-forum/how-to-query-reference-field-using-script/m-p/1875428#M532354</link>
      <description>&lt;P&gt;Hello Sudesh,&lt;/P&gt;
&lt;P&gt;Just wanted to check with you, if the above response answered your question.&lt;EM&gt;&lt;STRONG&gt; If yes, then please do close this thread/question by marking the appropriate response as correct.&lt;/STRONG&gt;&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;Thanks&lt;/P&gt;</description>
      <pubDate>Fri, 23 Sep 2022 05:29:53 GMT</pubDate>
      <guid>https://www.servicenow.com/community/developer-forum/how-to-query-reference-field-using-script/m-p/1875428#M532354</guid>
      <dc:creator>Mahendra RC</dc:creator>
      <dc:date>2022-09-23T05:29:53Z</dc:date>
    </item>
  </channel>
</rss>

