<?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 Advance Reference Qualifier depending on other field in ITSM forum</title>
    <link>https://www.servicenow.com/community/itsm-forum/advance-reference-qualifier-depending-on-other-field/m-p/2657751#M501850</link>
    <description>&lt;P&gt;Hi All,&lt;/P&gt;&lt;P&gt;On the form there are two fields&lt;/P&gt;&lt;P&gt;one is parent field and one is type field. As type changes to 1 I want parent filed should only show the record with which are type 1 and when type 2 is selected, the parent filed should show type 1 and type 2 record.&lt;/P&gt;&lt;P&gt;I tried coding few times but its only showing either type 1 records for all the type or its showing type 1 and 2 records for all the types, its not changing as we change the type filed.&lt;/P&gt;&lt;P&gt;I am using advance reference qualifier with script include. Any suggestion or improvised code would be helpful.&lt;/P&gt;&lt;P&gt;Thank you in Advance&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Please refer the image for code&lt;/P&gt;</description>
    <pubDate>Thu, 31 Aug 2023 05:44:15 GMT</pubDate>
    <dc:creator>Gaurav Rotke1</dc:creator>
    <dc:date>2023-08-31T05:44:15Z</dc:date>
    <item>
      <title>Advance Reference Qualifier depending on other field</title>
      <link>https://www.servicenow.com/community/itsm-forum/advance-reference-qualifier-depending-on-other-field/m-p/2657751#M501850</link>
      <description>&lt;P&gt;Hi All,&lt;/P&gt;&lt;P&gt;On the form there are two fields&lt;/P&gt;&lt;P&gt;one is parent field and one is type field. As type changes to 1 I want parent filed should only show the record with which are type 1 and when type 2 is selected, the parent filed should show type 1 and type 2 record.&lt;/P&gt;&lt;P&gt;I tried coding few times but its only showing either type 1 records for all the type or its showing type 1 and 2 records for all the types, its not changing as we change the type filed.&lt;/P&gt;&lt;P&gt;I am using advance reference qualifier with script include. Any suggestion or improvised code would be helpful.&lt;/P&gt;&lt;P&gt;Thank you in Advance&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Please refer the image for code&lt;/P&gt;</description>
      <pubDate>Thu, 31 Aug 2023 05:44:15 GMT</pubDate>
      <guid>https://www.servicenow.com/community/itsm-forum/advance-reference-qualifier-depending-on-other-field/m-p/2657751#M501850</guid>
      <dc:creator>Gaurav Rotke1</dc:creator>
      <dc:date>2023-08-31T05:44:15Z</dc:date>
    </item>
    <item>
      <title>Re: Advance Reference Qualifier depending on other field</title>
      <link>https://www.servicenow.com/community/itsm-forum/advance-reference-qualifier-depending-on-other-field/m-p/2657760#M501852</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;Please provide more details, such as scripts and screen shots.&lt;/P&gt;</description>
      <pubDate>Wed, 30 Aug 2023 14:34:54 GMT</pubDate>
      <guid>https://www.servicenow.com/community/itsm-forum/advance-reference-qualifier-depending-on-other-field/m-p/2657760#M501852</guid>
      <dc:creator>OlaN</dc:creator>
      <dc:date>2023-08-30T14:34:54Z</dc:date>
    </item>
    <item>
      <title>Re: Advance Reference Qualifier depending on other field</title>
      <link>https://www.servicenow.com/community/itsm-forum/advance-reference-qualifier-depending-on-other-field/m-p/2658281#M501879</link>
      <description>&lt;P&gt;Thank you for the reply, added the script in the question.&lt;/P&gt;</description>
      <pubDate>Thu, 31 Aug 2023 05:36:24 GMT</pubDate>
      <guid>https://www.servicenow.com/community/itsm-forum/advance-reference-qualifier-depending-on-other-field/m-p/2658281#M501879</guid>
      <dc:creator>Gaurav Rotke1</dc:creator>
      <dc:date>2023-08-31T05:36:24Z</dc:date>
    </item>
    <item>
      <title>Re: Advance Reference Qualifier depending on other field</title>
      <link>https://www.servicenow.com/community/itsm-forum/advance-reference-qualifier-depending-on-other-field/m-p/2658293#M501881</link>
      <description>&lt;P&gt;Hi &lt;a href="https://www.servicenow.com/community/user/viewprofilepage/user-id/259606"&gt;@Gaurav Rotke1&lt;/a&gt;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Try this in advanced reference qualifier with updating the field name and type values. Let me know it works or not?&lt;/P&gt;
&lt;LI-CODE lang="javascript"&gt;javascript&amp;amp;colon; if (current.type == 'type1') {
	"active=true^type=type1";
} else if (current.type == 'type2') {
	"active=true^type=type1^ORtype=type2";
} else {
	"active=true";
}&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If my response helps to solve your issue. Kindly mark it as helpful &amp;amp; correct. It will be helpful for future readers! &lt;span class="lia-unicode-emoji" title=":thumbs_up:"&gt;👍🏻&lt;/span&gt;&lt;BR /&gt;&lt;STRONG&gt;Thanks,&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;Sagar Pagar&lt;/STRONG&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 31 Aug 2023 06:01:29 GMT</pubDate>
      <guid>https://www.servicenow.com/community/itsm-forum/advance-reference-qualifier-depending-on-other-field/m-p/2658293#M501881</guid>
      <dc:creator>Sagar Pagar</dc:creator>
      <dc:date>2023-08-31T06:01:29Z</dc:date>
    </item>
    <item>
      <title>Re: Advance Reference Qualifier depending on other field</title>
      <link>https://www.servicenow.com/community/itsm-forum/advance-reference-qualifier-depending-on-other-field/m-p/2658307#M501882</link>
      <description>&lt;P&gt;Hi Sagar,&lt;/P&gt;&lt;P&gt;Its only working as a simple reference qualifier and only satiesfying one condition, as its doing for my code.&lt;/P&gt;</description>
      <pubDate>Thu, 31 Aug 2023 06:18:36 GMT</pubDate>
      <guid>https://www.servicenow.com/community/itsm-forum/advance-reference-qualifier-depending-on-other-field/m-p/2658307#M501882</guid>
      <dc:creator>Gaurav Rotke1</dc:creator>
      <dc:date>2023-08-31T06:18:36Z</dc:date>
    </item>
    <item>
      <title>Re: Advance Reference Qualifier depending on other field</title>
      <link>https://www.servicenow.com/community/itsm-forum/advance-reference-qualifier-depending-on-other-field/m-p/2658651#M501897</link>
      <description>&lt;P&gt;So, I've reviewed your images, and re-read the question.&lt;/P&gt;
&lt;P&gt;Basically it should work, but I'll provide some pointers to look at.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;When calling the script include, you need to include parentheses after the class name, like this:&lt;/P&gt;
&lt;P&gt;javascript&amp;amp;colon; new scoped_application.ParentFilter&lt;STRONG&gt;()&lt;/STRONG&gt;.parent(current.sys_id.toString());&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Like Sagar Pagar already suggested, it seems unnecessary to do another query in the script include.&lt;/P&gt;
&lt;P&gt;It will be enough if you return a valid encoded query as a qualifier, and you already have that in the script.&lt;/P&gt;
&lt;P&gt;So the script could be a lot simpler (example below).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Make it a habit to use the getValue() method, when retrieving data from the record.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Also make sure you have an else-statement in case no record was found, or not a valid value was found.&lt;/P&gt;
&lt;P&gt;You should have a default query to use in those cases.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="javascript"&gt;parent: function(recordID){

  var type = '';
  var resultEncodedQuery = '';

  var someGR = new GlideRecord('tablename');
  if (someGR.get(recordID)){
    type = someGR.getValue('u_type');  // use getValue

    if (type == 'Type A'){
	resultEncodedQuery = 'active=true^tablename_type=' + type;
    }
    else if (type == 'Type B'){
	resultEncodedQuery = 'active=true^tablename_type=' + type + '^ORtablename_type=Type A';
    }
    else {
	resultEncodedQuery = 'active=true';  // add a default query
    }

  }
  else {
	resultEncodedQuery = 'active=true';  // add a default query
  }

  return resultEncodedQuery; 
}
&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;And if it still isn't working, add debugging statements to verify you get a record, that the record has the value expected, and so on.&lt;/P&gt;</description>
      <pubDate>Thu, 31 Aug 2023 11:43:47 GMT</pubDate>
      <guid>https://www.servicenow.com/community/itsm-forum/advance-reference-qualifier-depending-on-other-field/m-p/2658651#M501897</guid>
      <dc:creator>OlaN</dc:creator>
      <dc:date>2023-08-31T11:43:47Z</dc:date>
    </item>
    <item>
      <title>Re: Advance Reference Qualifier depending on other field</title>
      <link>https://www.servicenow.com/community/itsm-forum/advance-reference-qualifier-depending-on-other-field/m-p/2659218#M501937</link>
      <description>&lt;P&gt;In what case is it working/not working?&amp;nbsp; Have you checked the "Value"s of your Choice List items for "Type" (I'm assuming a Choice list).&lt;/P&gt;</description>
      <pubDate>Thu, 31 Aug 2023 20:11:06 GMT</pubDate>
      <guid>https://www.servicenow.com/community/itsm-forum/advance-reference-qualifier-depending-on-other-field/m-p/2659218#M501937</guid>
      <dc:creator>Jim Coyne</dc:creator>
      <dc:date>2023-08-31T20:11:06Z</dc:date>
    </item>
  </channel>
</rss>

