How to get a list of unique values of some field from a table?

As the title suggests, I am wondering if it is possible to retrieve all unique values from a specific field in a table. So far, the only method I’ve found involves fetching all the data and then processing it to obtain the unique values. However, this approach is inefficient and impractical when dealing with large datasets.

The desired outcome is similar to the data displayed when filtering a data grid table using the “in” operator, where we see a list of distinct values that can be selected.

Screenshot_1

After selecting the “in” option we get all the different unique values that can than be selected.

Screenshot_2

I noticed that this behavior is achieved through an API call when the “in” operator is selected:
https://test-tabidoo.blitzgroup.eu/api/userdata/getDistinctValuesFromUserDataItemSafe

Is there a function or method that can accomplish something similar, or an alternative approach to achieving this result?

Additionally, it would be helpful to know if it is possible to add unique constraint for some field next to filters in options when calling the getCount() function.

Hello,
I would use the “Data Source” extension for that. You can define a data source grouped by some field and then you are able to load it:

await doo.extensions.customDataSource.getData('Datasource Name');

Regards

1 Like