Check if attribute value exist in before inserting

0
In my application, I there's an entity which I need to populate.   Preference is an Enum with value (one, two, three). While inserting a new object, I need to check, if the same preference has been given before, and if it is there, give the user a message. Right now, I've created a microflow on the save button where I'm getting the results from the database.   Any suggestions, how to change the hard-coded 'first' to the one user used while inserting the values?  Also, how to provide user an error if a value exisit, or insert if it doesn't    
asked
1 answers
0

You can accomplish by adding a Before commit event to the entity.  This will trigger a microflow where you can do this retrieve and add an exclusive split. If it doesnt exist, return true, and if it does exist return false. If you return false in this microflow it wont commit the object. 

 

To do the check to see if the preference is the same, you would check the field that says "pass event object" , and that will be your parameter of the microflow. You can retrieve all the applications associated to that user, and the use the list operation find to see if there is a duplicate  (If the list operation returns an object then there is a duplicate).

 

Alternatively, instead of using an event handler you can use a microflow as a custom save button. In the microflow you can do the duplicate check, and show a message to the user.

 

Here is the documentation for event handlers and list operations. 

 

https://docs.mendix.com/refguide/event-handlers

 

https://docs.mendix.com/refguide/list-operation

answered