List Collector variable multiple duplicate values

GraurSebastian
Tera Contributor

Hello, 

I want to display the values from a field from a table, but the i want to choose multiple choices so i have created a list collector, but the problem is that the variable is showing me all the records with the value form the field that i want, how can i make it to show me just one value each?

GraurSebastian_0-1711102478440.png

 

4 REPLIES 4

Dr Atul G- LNG
Tera Patron
Tera Patron

You can update the reference qualifier to see only one record of each or check why these values are duplicate in Source table. 

*************************************************************************************************************
If my response proves useful, please indicate its helpfulness by selecting " Accept as Solution" and " Helpful." This action benefits both the community and me.

Regards
Dr. Atul G. - Learn N Grow Together
ServiceNow Techno - Functional Trainer
LinkedIn: https://www.linkedin.com/in/dratulgrover
YouTube: https://www.youtube.com/@LearnNGrowTogetherwithAtulG
Topmate: https://topmate.io/atul_grover_lng [ Connect for 1-1 Session]

****************************************************************************************************************

Can you gave an example for ref qual that show just one record?

Hi @GraurSebastian 

 

AGLearnNGrow_0-1711103795398.png

 

*************************************************************************************************************
If my response proves useful, please indicate its helpfulness by selecting " Accept as Solution" and " Helpful." This action benefits both the community and me.

Regards
Dr. Atul G. - Learn N Grow Together
ServiceNow Techno - Functional Trainer
LinkedIn: https://www.linkedin.com/in/dratulgrover
YouTube: https://www.youtube.com/@LearnNGrowTogetherwithAtulG
Topmate: https://topmate.io/atul_grover_lng [ Connect for 1-1 Session]

****************************************************************************************************************

M Ismail
Tera Guru

Hi @GraurSebastian,

To achieve this, you can create a Script Include in ServiceNow and then call it from your reference qualifier. Here's how you can do it:

1. **Create a Script Include**:

Go to `System Definition` > `Script Includes` and create a new one. Let's name it `UserReferenceQualifier`.

Here's a sample code for the Script Include:


var UserReferenceQualifier = Class.create();
UserReferenceQualifier.prototype = {
initialize: function() {},

// Function to get the reference qualifier for User field in Incident table
getUserReferenceQualifier: function() {
var gr = new GlideRecord('incident');
gr.query();
var userIDs = [];
while (gr.next()) {
userIDs.push(gr.user.toString()); // Assuming 'user' is the reference field
}
return 'sys_idNOT IN (' + userIDs.join(',') + ')';
},

type: 'UserReferenceQualifier'
};
```

2. **Call the Script Include from Reference Qualifier**:

Now, you can use this Script Include in your reference qualifier script. Assuming you're setting the reference qualifier for the `user` field on the `incident` table:


var refQualifier = new UserReferenceQualifier();
refQualifier.getUserReferenceQualifier();
```

This setup will ensure that the reference field for users in the incident table does not display duplicate entries in the list collector.
This is just example, you can do for your field.

Please hit helpful and accept this as a solution if it solved your problem.
Thank you!