Eliminate duplicate in an array

Hello,

For context, i am getting data from an API, i have a list of article and a storage place associate with every article. So one storage can be associate with multiple article.

My final goal is to have a list of unique storage place.

I have all the storage place in an array i want to transform it to an array with unique value.

i achieve my goal with a loop, but it’s so slow to run it.

Maybe there is a other solution

Thanks for the feedback

@Faustin, this is a great question. I don’t have a suggestion off of the top of my head for this, and we don’t have unique values filter for our GET table endpoints. I’m going to check around and see if we haven’t figured out a more elegant way to do this internally, and I’ll report back if I find anything.

Hi @John,

I have another (but similar) use case, where this would be really handy:

Think of a Interactive Table, with order numbers, order description, order status, and work center.

You want to provide filters.
Order number and description are a simple text input.
However for status and work center, you want to provide only available values.

Easy: Map_To_Text_List(@variable.order_list, 'status') and Map_To_Text_List(@variable.order_list, 'work center')
but unfortunately all values are repetitive as often as they are in the table…

Eliminate duplicates here would be awesome!

@Faustin
I also would like an implemented solution.
However, here is how I made a custom widget for unique Values in an array:

JavaScript:

let list;
let uniqueList;

getValue("Text_List_Input", (internalVariable) => {
	list = internalVariable;
	uniqueList = [...new Set(list)];
	setValue("Text_List_Input", uniqueList);
	});

CSS ( only a green box to find the widget, you can delete everything else):

body {
	background-color: green;
}

Maybe that helps…

3 Likes

Hi Thorsten,
thanks for sharing. This custom widget will solve an actual problem I had.

Regards Chris

1 Like