How to create a foreach that reads all names inside an entity? I don't want duplicate

In fact our problem is the following:

1- We've created an entity to store unique names [role name];

2- We couldn't use a static entity because we need to insert data at run time;

3- How can we certify that we don't have duplicated data?;

4- How can we build an ForEach to get all names and compare with the user's input?

Solution

Hi Meta3Group

3- You can create a UniqueIndex in your entity for your Name attribute:

4- On aggregate you can filter the collumn with a value that user typed

Solution

Eduardo Pires wrote:

4- On aggregate you can filter the collumn with a value that user typed

Yes create an Aggregate that filters using Id and Name. If the list is empty then proceed otherwise, throw an error message or any warning to the user.


Hi, Eduardo Pires!
So, how can i edit the error message of the UniqueIndex?

Hi Meta3Group

3- You can create a UniqueIndex in your entity for your Name attribute:

4- On aggregate you can filter the collumn with a value that user typed



Create a CreateOrUpdate action that performce the following actions:

- Aggregate that checks wether the name exists

- Use the system entity action to CreateOrUpdate the record


Add a Exception handler that catches the Database exception, and return the functional error message.

Meta3Group wrote:

Hi, Eduardo Pires!
So, how can i edit the error message of the UniqueIndex?

Hi Meta3Group

3- You can create a UniqueIndex in your entity for your Name attribute:

4- On aggregate you can filter the collumn with a value that user typed




Hi Meta3Group,


You just need to put one Exception Handler on your flow!

Something like this: 

Or you can just do what the Matthias Preuter said.