26
Views
4
Comments
Solved
limit the same entry in one column
Application Type
Traditional Web

Hello,

I created a Table (Customers) with attributes like "Name", "Adress", "eMail", etc..

A form was created automatically. 
Now I want that a specific entry can exist only 5 times.

For example:
If in the Column "Adress" exist the word/entry 'ENDLICH' 5 times, the System should avoid the 6th entry, if the user type 'Endlich' in "Adress".


How can I solve it?

This is the form:

This is my Aggregate:
I tried the Count-Method, but this transformed my Entity to a structure. 
Any other Count-method I dont know.

I need the validation in the logical Side.
I tried any If-conditions but without success.
I use ODC Studio

Best regards

Solution

Hello Sezer

You can easily restrict the 6th entry of same address all you have to do is 

  • On save button logic call a server action and pass the current address which is filled by user to the server action.
  • Inside server action call an aggregate which fetches your Customer Entity.
  • Apply a filter Address(Input parameter) = Customer.Address
  • It will fetch all the records with that address if any previously stored.
  • After the aggregate drag an if condition an check the length of the aggregate list.
  • Like, GetCustomer.List.Length > 5
  • If the length is greater then 5 take a boolean output variable and assign it FALSE
  • If its less than 5 assign output TRUE
  • Now back to the save button logic check the output of server action.
  • If the output of server action is FALSE throw an Error message saying "this address exists 5 times" and end the flow.
  • If output is TRUE, Continue the Create/Update logic.

Hope this will help.

If found any difficulty, feel free to ask or can share your oml.

Regards 

Anees

Hello Mohd Anees,

first of all I thank you for your answer.

I followed your steps, it worked well up to a point, but either aggregating or the if-condition makes problems, because it doesn't work for me :/  

Here is my aggregate:

The filtering worked well, it shows me all entries of the same adress, if the user typed the adress, which you can test in the Test value section.

This is my if-condition: 

You can ignore the other aggregates. How you can see, is GetCustomerById3 the filtered relevant aggregate. Normally should this logic work, but it doesn. Idk why...
I built it first on the Client-Side, after then on the Server-Side.

Here is also the file:

I thank you a lot

workshop.oml

Hello sezer 

I am glad that it helped you.

Just swap the connecter of IF condition, If GetCustomer.List.Length > 5 

In TRUE branch Throw message "Too many entries", and FALSE branch Create/Update logic.

Thanks 

Anees


Hello Mohd Anees,

you are really great, thank you so much.

I swaped the connectors. 
It works only on the Server-Side (Run-Server-Action), on the Client-Side the same logic with the same connectors doesn't work for me. Client-side is much better to create e.g. Warning Messages.
But all in all was it very helpful. 
I wish you the best.
Best regards

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