Microflow with a decision before deleting a record

0
I have two tables person and state.Both are saved in the database where the person table communicates through id_cidade.   in mendix, I have a list with a registered person, for example, with the city São Paulo.   In the list of states, if I create a new state and then want to delete it, it deletes it normally, as the id is not related to a person record.But if I want to delete the state "São Paulo", for example, it gives an error warning that it cannot be turned off due to a connection with the id.   I want to create a decision, before the Execute Statement, that checks if the id of the selected state is linked to a registered person, and if so, display a message "Status cannot be deleted.", and if the id is not linked to either a person, the process continues to delete.   I already have a microflow with an "Execute Statement" that turns off logging. I just wanted to know what to do to make this decision before executing the deletion, so that I can display a message saying that it cannot be deleted.
asked
3 answers
0

If your entities are linked in the domain model you can just make a decision and then check if $entity1/link_to_entity2 is not empty, or empty, whatever your need is.

answered
0

The better way to do this would be to specify delete behavior. To do so, double click the association between the two entities and select "Delete State only when it is not associated with any Person objects"

 

image.png

answered
0

In the association's properties, it is like this.

Captura de tela 2024-03-06 163847.png

 

 

On the screen where the records appear, when I click to delete, the item is normally deleted when it is not associated with any other record.  But if you have an association, this message appears, as an attachment, advising you to contact the administrator.

Therefore, I wanted the operation to be canceled by displaying a message warning why it could not be deleted, without receiving another message asking to contact the administrator.

Captura de tela 2024-03-06 163729.png

answered