<?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: How to display only unique values from the Reference variable in Developer forum</title>
    <link>https://www.servicenow.com/community/developer-forum/how-to-display-only-unique-values-from-the-reference-variable/m-p/1735870#M392796</link>
    <description>&lt;P&gt;Add this script with a function named getUniqueCostCenters() and Call it in the advanced reference qualifier of cost center variables as&lt;/P&gt;
&lt;P&gt;javascript: new ScriptIncludeName().getUniqueCostCenters()&lt;/P&gt;</description>
    <pubDate>Mon, 07 Jan 2019 15:14:51 GMT</pubDate>
    <dc:creator>Alikutty A</dc:creator>
    <dc:date>2019-01-07T15:14:51Z</dc:date>
    <item>
      <title>How to display only unique values from the Reference variable</title>
      <link>https://www.servicenow.com/community/developer-forum/how-to-display-only-unique-values-from-the-reference-variable/m-p/1735854#M392780</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;We have a variable Reference Type which is referring to Assignment Group. Our Assignment Group contains duplicate group names ex: Test Group, Test Group, Network, Network&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;
&lt;P&gt;From the Catalog view when the user clicks or search for the Assingment Group we need to display only unique value like if the user types Network, it should display only Network once not multiple&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;How to acheive this&lt;/P&gt;</description>
      <pubDate>Mon, 07 Jan 2019 09:38:25 GMT</pubDate>
      <guid>https://www.servicenow.com/community/developer-forum/how-to-display-only-unique-values-from-the-reference-variable/m-p/1735854#M392780</guid>
      <dc:creator>shaik_irfan</dc:creator>
      <dc:date>2019-01-07T09:38:25Z</dc:date>
    </item>
    <item>
      <title>Re: How to display only unique values from the Reference variable</title>
      <link>https://www.servicenow.com/community/developer-forum/how-to-display-only-unique-values-from-the-reference-variable/m-p/1735855#M392781</link>
      <description>&lt;P&gt;Hello Shaik,&lt;/P&gt;
&lt;P&gt;You can change the Type of Variable to Lookup Select Box and make sure you check unique values only under Type Specifications.&lt;/P&gt;
&lt;P&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/204230i1634532C7F5853C5/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&gt;Please try and let me know&lt;/P&gt;
&lt;P&gt;Thanks&lt;/P&gt;</description>
      <pubDate>Mon, 07 Jan 2019 09:44:35 GMT</pubDate>
      <guid>https://www.servicenow.com/community/developer-forum/how-to-display-only-unique-values-from-the-reference-variable/m-p/1735855#M392781</guid>
      <dc:creator>Alikutty A</dc:creator>
      <dc:date>2019-01-07T09:44:35Z</dc:date>
    </item>
    <item>
      <title>Re: How to display only unique values from the Reference variable</title>
      <link>https://www.servicenow.com/community/developer-forum/how-to-display-only-unique-values-from-the-reference-variable/m-p/1735856#M392782</link>
      <description>&lt;P&gt;May i know What is the reason you have multiple group names with same name?&lt;/P&gt;
&lt;P&gt;Thanks,&lt;/P&gt;
&lt;P&gt;Siva&lt;/P&gt;</description>
      <pubDate>Mon, 07 Jan 2019 09:46:17 GMT</pubDate>
      <guid>https://www.servicenow.com/community/developer-forum/how-to-display-only-unique-values-from-the-reference-variable/m-p/1735856#M392782</guid>
      <dc:creator>siva_</dc:creator>
      <dc:date>2019-01-07T09:46:17Z</dc:date>
    </item>
    <item>
      <title>Re: How to display only unique values from the Reference variable</title>
      <link>https://www.servicenow.com/community/developer-forum/how-to-display-only-unique-values-from-the-reference-variable/m-p/1735857#M392783</link>
      <description>&lt;P&gt;Cant we implement the same on Reference type ?&lt;/P&gt;</description>
      <pubDate>Mon, 07 Jan 2019 11:51:38 GMT</pubDate>
      <guid>https://www.servicenow.com/community/developer-forum/how-to-display-only-unique-values-from-the-reference-variable/m-p/1735857#M392783</guid>
      <dc:creator>shaik_irfan</dc:creator>
      <dc:date>2019-01-07T11:51:38Z</dc:date>
    </item>
    <item>
      <title>Re: How to display only unique values from the Reference variable</title>
      <link>https://www.servicenow.com/community/developer-forum/how-to-display-only-unique-values-from-the-reference-variable/m-p/1735858#M392784</link>
      <description>&lt;P&gt;You will need to write a advanced scripted reference qualifier to remove duplicates and display it on the reference variable. This is not a recommended approach, You should not allow duplicate group names on your group table and prevent it from creation by marking the unique flag on the name column on sys_user_group table.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 07 Jan 2019 12:02:47 GMT</pubDate>
      <guid>https://www.servicenow.com/community/developer-forum/how-to-display-only-unique-values-from-the-reference-variable/m-p/1735858#M392784</guid>
      <dc:creator>Alikutty A</dc:creator>
      <dc:date>2019-01-07T12:02:47Z</dc:date>
    </item>
    <item>
      <title>Re: How to display only unique values from the Reference variable</title>
      <link>https://www.servicenow.com/community/developer-forum/how-to-display-only-unique-values-from-the-reference-variable/m-p/1735859#M392785</link>
      <description>&lt;P&gt;Write an Advanced Reference Qualifier and call script include&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;** Note: Below script is not tested&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&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/204229i2C9BE4981D219C38/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&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&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/204237iCBB26E0E25BCCF2D/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;</description>
      <pubDate>Mon, 07 Jan 2019 12:27:43 GMT</pubDate>
      <guid>https://www.servicenow.com/community/developer-forum/how-to-display-only-unique-values-from-the-reference-variable/m-p/1735859#M392785</guid>
      <dc:creator>Chalan B L</dc:creator>
      <dc:date>2019-01-07T12:27:43Z</dc:date>
    </item>
    <item>
      <title>Re: How to display only unique values from the Reference variable</title>
      <link>https://www.servicenow.com/community/developer-forum/how-to-display-only-unique-values-from-the-reference-variable/m-p/1735860#M392786</link>
      <description>&lt;P&gt;Chalan,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I tried with your script but it is not working :(.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Am i missing anything ?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Script Include:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&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/204231i50487031CFF2D6FA/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&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Reference Type variable referene qualifier:&lt;/P&gt;
&lt;P&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/204238i0FEFAD1BFB564ADB/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&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 07 Jan 2019 13:03:54 GMT</pubDate>
      <guid>https://www.servicenow.com/community/developer-forum/how-to-display-only-unique-values-from-the-reference-variable/m-p/1735860#M392786</guid>
      <dc:creator>shaik_irfan</dc:creator>
      <dc:date>2019-01-07T13:03:54Z</dc:date>
    </item>
    <item>
      <title>Re: How to display only unique values from the Reference variable</title>
      <link>https://www.servicenow.com/community/developer-forum/how-to-display-only-unique-values-from-the-reference-variable/m-p/1735861#M392787</link>
      <description>&lt;P&gt;Irfan in the reference qualifier pass the &lt;STRONG&gt;variable name&lt;/STRONG&gt; you want to filter the duplicate names.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Let me know the backend name of the variable you are trying for ??&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Mark correct if it helped you..!!!&lt;/P&gt;
&lt;P&gt;Regards,&lt;/P&gt;
&lt;P&gt;Chalan&lt;/P&gt;</description>
      <pubDate>Mon, 07 Jan 2019 13:12:39 GMT</pubDate>
      <guid>https://www.servicenow.com/community/developer-forum/how-to-display-only-unique-values-from-the-reference-variable/m-p/1735861#M392787</guid>
      <dc:creator>Chalan B L</dc:creator>
      <dc:date>2019-01-07T13:12:39Z</dc:date>
    </item>
    <item>
      <title>Re: How to display only unique values from the Reference variable</title>
      <link>https://www.servicenow.com/community/developer-forum/how-to-display-only-unique-values-from-the-reference-variable/m-p/1735862#M392788</link>
      <description>&lt;P&gt;Hello Irfan,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Any updates here if it helped you could you please mark the answer correct..!!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Regards,&lt;/P&gt;
&lt;P&gt;Chalan&lt;/P&gt;</description>
      <pubDate>Mon, 07 Jan 2019 14:10:00 GMT</pubDate>
      <guid>https://www.servicenow.com/community/developer-forum/how-to-display-only-unique-values-from-the-reference-variable/m-p/1735862#M392788</guid>
      <dc:creator>Chalan B L</dc:creator>
      <dc:date>2019-01-07T14:10:00Z</dc:date>
    </item>
    <item>
      <title>Re: How to display only unique values from the Reference variable</title>
      <link>https://www.servicenow.com/community/developer-forum/how-to-display-only-unique-values-from-the-reference-variable/m-p/1735863#M392789</link>
      <description>&lt;P&gt;He is looking to compare all names from group table and remove duplicates in it. So in group table, if you have 100 groups and several duplicates, it should return unique entries in the reference field.&lt;/P&gt;</description>
      <pubDate>Mon, 07 Jan 2019 14:14:47 GMT</pubDate>
      <guid>https://www.servicenow.com/community/developer-forum/how-to-display-only-unique-values-from-the-reference-variable/m-p/1735863#M392789</guid>
      <dc:creator>Alikutty A</dc:creator>
      <dc:date>2019-01-07T14:14:47Z</dc:date>
    </item>
    <item>
      <title>Re: How to display only unique values from the Reference variable</title>
      <link>https://www.servicenow.com/community/developer-forum/how-to-display-only-unique-values-from-the-reference-variable/m-p/1735864#M392790</link>
      <description>&lt;P&gt;Variable name is Center &amp;amp; Cost Center table field name is name.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Do i need to change in Scirpt Include &amp;amp; Ref Qualifier or only Ref Qualifier ?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Variable Name:&lt;/P&gt;
&lt;P&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/204228i76F78AEE02C620BF/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&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Cost Center whcih is a Referring table:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&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/204227i428EAE2026D68772/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&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Advanced Script:&lt;/P&gt;
&lt;P&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/204232i0A43D8B193D64389/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&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Script Include: I tried keeping as Center too but it is not working in the scriptinclude function and unique field script line&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&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/204236i9BD4F876716D57A2/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&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 07 Jan 2019 14:19:53 GMT</pubDate>
      <guid>https://www.servicenow.com/community/developer-forum/how-to-display-only-unique-values-from-the-reference-variable/m-p/1735864#M392790</guid>
      <dc:creator>shaik_irfan</dc:creator>
      <dc:date>2019-01-07T14:19:53Z</dc:date>
    </item>
    <item>
      <title>Re: How to display only unique values from the Reference variable</title>
      <link>https://www.servicenow.com/community/developer-forum/how-to-display-only-unique-values-from-the-reference-variable/m-p/1735865#M392791</link>
      <description>&lt;P&gt;Hello Irfan ,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The way you called the script include in the reference qualifier is correct but the thing which you are missing is&amp;nbsp;&lt;/P&gt;
&lt;P&gt;after doing the processing that needs to be done in script include you are getting the items into an array but you are not filtering the duplicates as expected (i mean you are directly returning the array with the names from your script include and that doesnot work)&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;To make it work , you have to get the sys ids as an comma seperated list of values as you are returning the values to a reference field , it can only display records based on the set of sysid's&amp;nbsp;&lt;/P&gt;
&lt;P&gt;so into your array you can get set of sys_id values and you can use Array.join() after the ArrayUtil.unique() line&amp;nbsp;&lt;/P&gt;
&lt;P&gt;and assign those values to a variable and while returning you can use return "sys_idIN"+varName&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Hope that helps&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks,&lt;/P&gt;
&lt;P&gt;Siva&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;MARK THIS RESPONSE AS CORRECT IF THAT REALLY HELPS&lt;/STRONG&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 07 Jan 2019 14:20:16 GMT</pubDate>
      <guid>https://www.servicenow.com/community/developer-forum/how-to-display-only-unique-values-from-the-reference-variable/m-p/1735865#M392791</guid>
      <dc:creator>siva_</dc:creator>
      <dc:date>2019-01-07T14:20:16Z</dc:date>
    </item>
    <item>
      <title>Re: How to display only unique values from the Reference variable</title>
      <link>https://www.servicenow.com/community/developer-forum/how-to-display-only-unique-values-from-the-reference-variable/m-p/1735866#M392792</link>
      <description>&lt;P&gt;I missed this in the code Irfan&lt;/P&gt;
&lt;P&gt;----------------------------------------------&lt;/P&gt;
&lt;P&gt;var arrayUtil = new ArrayUtil();&lt;/P&gt;
&lt;P&gt;var store = arrayUtil.unique(duplicateFieldName);&lt;/P&gt;
&lt;P&gt;return 'sys_idIN'+store.toString();&lt;/P&gt;
&lt;P&gt;--------------------------------------------&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Mark the answer as correct and helpful if it helped you..!!!&lt;/P&gt;</description>
      <pubDate>Mon, 07 Jan 2019 14:27:15 GMT</pubDate>
      <guid>https://www.servicenow.com/community/developer-forum/how-to-display-only-unique-values-from-the-reference-variable/m-p/1735866#M392792</guid>
      <dc:creator>Chalan B L</dc:creator>
      <dc:date>2019-01-07T14:27:15Z</dc:date>
    </item>
    <item>
      <title>Re: How to display only unique values from the Reference variable</title>
      <link>https://www.servicenow.com/community/developer-forum/how-to-display-only-unique-values-from-the-reference-variable/m-p/1735867#M392793</link>
      <description>&lt;P&gt;Thank you, Now i dont see any record all gets disapperead &lt;span class="lia-unicode-emoji" title=":disappointed_face:"&gt;😞&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&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/204234i289BCCC15AD52ACF/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&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Script Include:&lt;/P&gt;
&lt;P&gt;var ScriptIncludeName = Class.create();&lt;BR /&gt;ScriptIncludeName.prototype = {&lt;BR /&gt; scriptIncludeFunctionName: function(duplicateFieldName) {&lt;BR /&gt; var arrayUtil = new ArrayUtil();&lt;/P&gt;
&lt;P&gt;var store = arrayUtil.unique(duplicateFieldName);&lt;/P&gt;
&lt;P&gt;return 'sys_idIN'+store.toString();&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt; },&lt;/P&gt;
&lt;P&gt;type: 'ScriptIncludeName'&lt;BR /&gt;};&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 07 Jan 2019 15:06:12 GMT</pubDate>
      <guid>https://www.servicenow.com/community/developer-forum/how-to-display-only-unique-values-from-the-reference-variable/m-p/1735867#M392793</guid>
      <dc:creator>shaik_irfan</dc:creator>
      <dc:date>2019-01-07T15:06:12Z</dc:date>
    </item>
    <item>
      <title>Re: How to display only unique values from the Reference variable</title>
      <link>https://www.servicenow.com/community/developer-forum/how-to-display-only-unique-values-from-the-reference-variable/m-p/1735868#M392794</link>
      <description>&lt;P&gt;In above response am i missing anything ?&lt;/P&gt;</description>
      <pubDate>Mon, 07 Jan 2019 15:07:10 GMT</pubDate>
      <guid>https://www.servicenow.com/community/developer-forum/how-to-display-only-unique-values-from-the-reference-variable/m-p/1735868#M392794</guid>
      <dc:creator>shaik_irfan</dc:creator>
      <dc:date>2019-01-07T15:07:10Z</dc:date>
    </item>
    <item>
      <title>Re: How to display only unique values from the Reference variable</title>
      <link>https://www.servicenow.com/community/developer-forum/how-to-display-only-unique-values-from-the-reference-variable/m-p/1735869#M392795</link>
      <description>&lt;P&gt;Hi Shaik,&lt;/P&gt;
&lt;P&gt;You can try this script in your script include&lt;/P&gt;
&lt;PRE class="language-javascript"&gt;&lt;CODE&gt;var ccList = [];
var uniqueArr = [];
var arrayUtil = new ArrayUtil();
var cc = new GlideRecord('cmn_cost_center');
cc.query();
while(cc.next()){
  ccList.push(cc.name);
}
uniqueArr = arrayUtil.unique(ccList);
return 'sys_idIN'+uniqueArr.toString();
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 07 Jan 2019 15:13:03 GMT</pubDate>
      <guid>https://www.servicenow.com/community/developer-forum/how-to-display-only-unique-values-from-the-reference-variable/m-p/1735869#M392795</guid>
      <dc:creator>Alikutty A</dc:creator>
      <dc:date>2019-01-07T15:13:03Z</dc:date>
    </item>
    <item>
      <title>Re: How to display only unique values from the Reference variable</title>
      <link>https://www.servicenow.com/community/developer-forum/how-to-display-only-unique-values-from-the-reference-variable/m-p/1735870#M392796</link>
      <description>&lt;P&gt;Add this script with a function named getUniqueCostCenters() and Call it in the advanced reference qualifier of cost center variables as&lt;/P&gt;
&lt;P&gt;javascript: new ScriptIncludeName().getUniqueCostCenters()&lt;/P&gt;</description>
      <pubDate>Mon, 07 Jan 2019 15:14:51 GMT</pubDate>
      <guid>https://www.servicenow.com/community/developer-forum/how-to-display-only-unique-values-from-the-reference-variable/m-p/1735870#M392796</guid>
      <dc:creator>Alikutty A</dc:creator>
      <dc:date>2019-01-07T15:14:51Z</dc:date>
    </item>
    <item>
      <title>Re: How to display only unique values from the Reference variable</title>
      <link>https://www.servicenow.com/community/developer-forum/how-to-display-only-unique-values-from-the-reference-variable/m-p/1735871#M392797</link>
      <description>&lt;P&gt;If the assignment group field has duplicate names , how are you managing exact assignment groups for all the records. Initially i suggest you to run a background script removing all the duplicate assignment groups&amp;nbsp;&lt;/P&gt;
&lt;P&gt;9&lt;/P&gt;
&lt;P&gt;Before that for the existing records you should also check if the assignment group(you are deleting) has already been assigned to a case and maintain a single unique assignment group with the same&amp;nbsp;sysid for every existing case, i strongly suggest that it would be the better approach as it may even incur multiple problems in reporting&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;We can prepare a code for the request by modifying what you have written but we cannot be sure how GlideRecord takes in when you query the same name for an assignment group what ever first record comes up it gives that sys id and that might become a mess ..&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Hope that helps&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;Mark this response as correct if that really helps&amp;nbsp;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks,&lt;/P&gt;
&lt;P&gt;Siva&lt;/P&gt;</description>
      <pubDate>Mon, 07 Jan 2019 16:48:36 GMT</pubDate>
      <guid>https://www.servicenow.com/community/developer-forum/how-to-display-only-unique-values-from-the-reference-variable/m-p/1735871#M392797</guid>
      <dc:creator>siva_</dc:creator>
      <dc:date>2019-01-07T16:48:36Z</dc:date>
    </item>
    <item>
      <title>Re: How to display only unique values from the Reference variable</title>
      <link>https://www.servicenow.com/community/developer-forum/how-to-display-only-unique-values-from-the-reference-variable/m-p/1735872#M392798</link>
      <description>&lt;P&gt;Few more changes are required to the above script, please try the script below&lt;/P&gt;
&lt;PRE class="language-javascript"&gt;&lt;CODE&gt;var ccList = [];
var uniqueArr = [];
var ids = [];
var arrayUtil = new ArrayUtil();
var cc = new GlideRecord('cmn_cost_center');
cc.query();
while(cc.next()){
  ccList.push(cc.name);
}
uniqueArr = arrayUtil.unique(ccList);

ccList = [];
var cc1 = new GlideRecord('cmn_cost_center');
cc1.addEncodedQuery('nameIN'+uniqueArr.toString());
cc1.query();
while(cc1.next()){
  ccList.push(cc1.sys_id);
}

return 'sys_idIN'+ccList.toString();&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 08 Jan 2019 06:32:45 GMT</pubDate>
      <guid>https://www.servicenow.com/community/developer-forum/how-to-display-only-unique-values-from-the-reference-variable/m-p/1735872#M392798</guid>
      <dc:creator>Alikutty A</dc:creator>
      <dc:date>2019-01-08T06:32:45Z</dc:date>
    </item>
    <item>
      <title>Re: How to display only unique values from the Reference variable</title>
      <link>https://www.servicenow.com/community/developer-forum/how-to-display-only-unique-values-from-the-reference-variable/m-p/1735873#M392799</link>
      <description>&lt;P&gt;Ali,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank you for the script but unfortunately it is not working &lt;span class="lia-unicode-emoji" title=":disappointed_face:"&gt;😞&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Advanced Rer Qualifier Screnshot:&lt;/P&gt;
&lt;P&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/204235iCA311117990F647C/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&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Script Include:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE class="language-javascript"&gt;&lt;CODE&gt;var ScriptIncludeName = Class.create();
ScriptIncludeName.prototype = Object.extendsObject(AbstractAjaxProcessor, {
getUniqueCostCenters: function(){
	var ccList = [];
var uniqueArr = [];
var ids = [];
var arrayUtil = new ArrayUtil();
var cc = new GlideRecord('cmn_cost_center');
cc.query();
while(cc.next()){
  ccList.push(cc.name);
}
uniqueArr = arrayUtil.unique(ccList);

ccList = [];
var cc1 = new GlideRecord('cmn_cost_center');
cc1.addEncodedQuery('nameIN'+uniqueArr.toString());
cc1.query();
while(cc1.next()){
  ccList.push(cc1.sys_id);
}

return 'sys_idIN'+ccList.toString();
},
	
    type: 'ScriptIncludeName'
});&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I see only 1 record other records got disapperaed.&lt;/P&gt;
&lt;P&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/204233iB0EBF646FFCF76B8/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&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 08 Jan 2019 06:40:09 GMT</pubDate>
      <guid>https://www.servicenow.com/community/developer-forum/how-to-display-only-unique-values-from-the-reference-variable/m-p/1735873#M392799</guid>
      <dc:creator>shaik_irfan</dc:creator>
      <dc:date>2019-01-08T06:40:09Z</dc:date>
    </item>
  </channel>
</rss>

