Dropdown containing only unique values
Question
Application Type
Reactive

Hello.


I have a Project aggregate containing several entities. One of the entities is Project Name. I'm saving the Project Name in a Back Office and then I want to display all of the Project Names in a dropdown on a different screen. My issue is that I want to display only unique project names, so they wouldn't repeat in the dropdown. 

ProjectDropdown.PNG

Hi @Dominka511


I completely agree with @Aadhavan Shanmugam and @Rui Barradas.

As per your problem statement, I created one demo application and attached it here for your reference.

Or To check go through this demo app link:

https://personal-6qqoqcvk.outsystemscloud.com/FilterDropdown/Test

 Please check and let me know if this will help you.


Regards,

Narendra Bhangale.

FilterDropdown.oml

mvp_badge
MVP

Hello there Dominka,

Hope you're doing well.

According to your image, your dropdown is bound to a list called GetProjects.List.

Most likely, you have some joins with another entities in that Aggregate that could explain the values to be repeated.

As a suggestion, you can always create a different Aggregate only with the Project Name entity, you can call it GetProjectNames and bound the dropdwon to the resulting list: GetProjectNames.List.


If you still have additional questions, please share your OML so we can take a look.


Kind regards,

Rui Barradas

Hello Rui.


Thank you for your reply.

The duplicated values are there because users will insert them there via the Back office. My users have a lot of Projects with the same name but they have a different Activity for each of the projects with the same name. So the idea is that they insert a lot of projects with the name ProjectX into the back office. But each ProjectX will have a different activity. On a different screen, they want a dropdown with different project Names. Once they select a Project name, only related Activities will appear in the next dropdown.

Unfortunately, I cannot share the entire OML but I'm sending you a screenshot of the GetProjects aggregate. As you can see there are 2 Projects with the name 25MY. I want the 25MY to appear only once in a dropdown.

Thank you.

Aggregate.PNG

mvp_badge
MVP

Hello Dominka,

Thank you for your explanation, now I understand why you have duplicated values and what you're trying to achieve.

There are indeed several ways to accomplish what you pretend.


Like I said before, my first suggestion would be the creation of a different Aggregate, in which you may have only Project Entity. Call it for instance GetProjectNames. Then you just need to group by ProjectName column and bound the returning list to your dropdown (instead of GetProjects.List).


For the next dropdown (activities related), you'll need to use On Change event from the first dropdown and filter these activities with the corresponding Project Name (selected in the first dropdown).


Kind regards,

Rui Barradas

Hi @Dominka511 ,

You can group the aggregate by "ProjectName" and the aggregate output will be distinct ProjectName.

Output:

You can use the aggregate output (ProjectName list) to your dropdown. Refer OML.

Good Luck!!

Thanks, Aadhavan S

Samplev19.oml

Thank you for your response.

I've tried that already but then my dropdown didn't work as expected and it also disabled the other entities.
I've tried using ListDistinct but either I'm using it wrong or it doesn't work in my case.

Hi @Dominka511 ,

It is OutSystems behavior. When you are using "GroupBy" in aggregate, the aggregate results in only the output (Grouped list).  You have to create another aggregate to fetch Project details based on ProjectName list.

In this way, only you can reduce the weightage of the current screen and get required output.

Thanks, Aadhavan S

Hi @Dominka511


I completely agree with @Aadhavan Shanmugam and @Rui Barradas.

As per your problem statement, I created one demo application and attached it here for your reference.

Or To check go through this demo app link:

https://personal-6qqoqcvk.outsystemscloud.com/FilterDropdown/Test

 Please check and let me know if this will help you.


Regards,

Narendra Bhangale.

FilterDropdown.oml

Thank you very much! That helped a LOT! I finally got it.

You're very welcome, It was my Pleasure! My suggestion helps to resolve your query.


Kind Regards,

Narendra Bhangale.

mvp_badge
MVP

Hi Dominka,

Based on the mentioned explanation, you are trying to implement the dependant dropdown use case.

There will be two dropdown

Dropdown 1 --> ProjectName 

Dropdown 2 --> ProjectActivities

But in your case, we do have a scenario: The Project entity can have multiple similar Project Name attribute values with different Activities, as shown below

So as a solution, I would suggest the same approach which is already mentioned by Aadhavan.

Implementation Steps:

  • Define a separate Aggregate1, to fetch the list of unique Project Names of which the output list will be mapped with the Dropdown 1
  • On change of the Dropdown 1, filter the Aggregate2 based on selected ProjectName text value instead of project identifier value and populate the Dropdown2 with Aggregate2 result-set.


Aggregate1 --> GetProjectNames (Group By ProjectName)

Aggregate2 ---> GetProjectActivities (Filter by Selected Dropdown1 Project Name value)

Note: When you define Group By attribute(s) in the aggregate, the Output list of the aggregate gets limited with only those attributes included in the Group By. If you Group By with the ProjectId attribute, you will get duplicate project names as query results.

I hope this helps you!


Kind regards,

Benjith Sam

Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.