cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

RAP - implement a validation on delete action

mouradche
Explorer
0 Kudos
1,649

Hi,
I have a very basic requirement in RAP. I want to implement a validation on a given field when the user deletes an entity (reject the deletion if a given field has a given value)
So I used this syntax in the Behavior Definition
validation checkDelete on save {delete;}
Now in the method checkDelete, when I try to retrieve the data of the entity to be deleted using READ ENTITY with keys it returns nothing as if the entity has already been deleted.
My question is what's the point of giving the possibility to perform a validation on delete action if we cannot access the entity data in the validation handler method and how could I implement my check.
I'm new in RAP so I'm maybe missing something here

Thank you for your help
Mourad

Accepted Solutions (1)

Accepted Solutions (1)

anoukvandenengel
Participant

Hi Mourad,

I think in this case it is easier to use instance feature control, e.g.:

 delete (features: instance);

This way you can enable/disable the delete option under certain conditions.

If this is not suiting your requirements, an alternative would be to do a select on your entity within the validation handler method to obtain the entity data.

I hope one of these options will help you.

mouradche
Explorer

Hi anoukvandenengel,

Thank you for the reply. I actually implemented the requirement using the precheck syntax :

delete (precheck); 

The logic is then implemented in the method precheck_delete( ) where I have access to the instance to be deleted as at this point the modification didn't reach the transnational buffer yet.
But your solution with feature control is also acceptable 🙂 

Regards,
Mourad 

anoukvandenengel
Participant
0 Kudos
Actually, this was exactly what I was looking for (while I stumbled upon your question), so thank you too for sharing this solution!

Answers (0)