List collector to show only the unique values returned from the script include ( remove the duplicate records)

Bhavana Reddy
Mega Guru

Hello Guys,

 

I have the List collector field, depending on the Opportunity i need to show only the Unique SVO No (display= true is set for this field in the table) please let me know how we can achieve this?

 

script include::

function QuoteDisplay(oppo) {
    gs.log("oppo:"+oppo);
    var oppo = new GlideRecord('x_784298_needit_sp_opportunity');
    oppo.get(this.getParameter('oppo'));
    var svoNo = [];
    var gr = new GlideAggregate('x_784298_needit_sp_sub_contract_test'); //GlideAggregate query
    gr.addAggregate('count'); 
    gr.groupBy('svo_no'); //Group aggregate by the 'os' field
    gr.addQuery('opportunity', oppo.sys_id);
    gr.query();
    while (gr.next()) {
        svoNo.push(gr.svo_no + '');
    
    }
    gs.log("svoNo arry::"+svoNo);
    return svoNo.toString();
}

in the reference qualifier, calling like this

find_real_file.png

For the selected Opportunity( in below screenshot ssss), i want to display the Unique quote associated to that in the list collector and it should show only the unique SVO No in the list collector

find_real_file.png

Can anyone please help me with this?

1 ACCEPTED SOLUTION

that's correct.

It's not possible

If my response helped please close the thread by marking appropriate response as correct so that it benefits future readers.

Regards
Ankur

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

View solution in original post

10 REPLIES 10

Chandu Telu
Tera Guru
Tera Guru

Hi,

Check the below similar point is answered

https://community.servicenow.com/community?id=community_question&sys_id=79c80b61db5cdbc01dcaf3231f961986

 

Thanks
Chandu Telu
Please Mark Correct/helpful, if applicable,

 

Aman Kumar S
Kilo Patron

Hey,

You can add three lines at the end:

var arrayUtil = new global.ArrayUtil();

var uniqueSVONo = arrayUtil.unique(svoNo);

return uniqueSVONo.toString() ;

 

Feel free to mark correct, If I answered your query.

Will be helpful for future visitors looking for similar questions 🙂

Best Regards
Aman Kumar

I am getting the unique values from the script include but i cannot set that value to the list collector...

not sure if its possible to achieve or not?

Ankur Bawiskar
Tera Patron
Tera Patron

Hi,

list collector will show records i.e. it holds sysIds which cannot be duplicate.

Now you need to investigate why the Number field in that Sub-Contract-tests table is repeated.

That should not ideally repeat if that Number field is an auto-number

What field is unique in your table?

Regards
Ankur

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader