I'm trying to avoid record deletion based on record and/or parent status. I've tried two options:

1. Trigger validation on before delete with a record and add Error message if it can't be deleted. Although it's quite ok, the page that it showed is not available in partner portal, it returns the exception page (which it's not ok)

2. So to avoid this I created a visualforce page to override the delete action for that object. It works fine for the delete button on detail page but does not override the delete action for a related list.

Now, I'm asking if anyone has any suggestions. Thanks! Pedro.

  • Hi Pedro, where do you have the validation when you use the VF page? – Carolina Jan 24 '14 at 11:08
  • Hi Carolina. I have it on the function related to the "action" attribute for the VF page – Pedro Ribeiro Jan 24 '14 at 12:35

I'm going to try to help :) Then I think that the issue that you have could be that the validation is in only related to the VF page. Then any other "deletes" are not going to have the same validation. I would recommend this: 1.-Create all your validations on the low level : triggers ( Also as far as possible try to create the validations on the after trigger) 2.- The VF page will be linked to a controller, and the controller will do the call to "Delete" 3.- The controller would format the error that the trigger will send and the controller will send the formatted error to the VF page to show to the user.

If the users click the other "deletes" the trigger will run always and won't allow them to delete the record.

Hope it helps.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.