Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-13-2024 08:35 PM
To remove duplicate values from an array obtained through GlideRecord, you can use JavaScript's Set object.
// Create a new Set object to store unique values
var uniqueValues = new Set();
// Iterate through the GlideRecord results
while (gr.next()) {
// Get the value of the column you want to make unique
var columnValue = gr.getValue('your_column_name_here');
// Add the value to the Set (which automatically removes duplicates)
uniqueValues.add(columnValue);
}
// Convert the Set back to an array
var uniqueArray = Array.from(uniqueValues);
- Set is a JavaScript object that stores unique values. By adding values to a Set, duplicates are automatically removed.
- Finally, you convert the Set back to an array using Array.from().
This way, uniqueArray will contain unique values extracted from the specified column in your GlideRecord results.
Please Mark ✅Correct if this solves your query and also mark 👍Helpful if you find my response worthy based on the impact.
Thanks