You need to sign in to do that
Don't have an account?
Aniche
Avoid Deletion of accounts through triggers
Can I prevent deletion of an account that comes through our ERP but allow prospects to get deleted... ?
I know i can override the button but i not very familiar with S-Controls.
I can distinguish between them though the prospect flag but dont know how to alert saying you cannot delete a account which is not propsect and there by make my trigger to work such that it avoids the deletion
Thanks in advance.
One is avoid deletion through and S-Control.
The other and more of what I think you mean is avoid deletion through an account trigger.
Both will get the the job done but they do it in different ways.
With the S-Control way you will have to override the delete button on accounts with an S-Control that has simple logic to check if the account is a prospect.
Then show the user a message if the account can not be deleted, then bring the user back to the details page of the account.
With the trigger you can use Trigger.isDelete to check if a user is deleting the account. Then in the trigger check to see if the account is a prospect.
Then show the user the Apex error message, just like the field validation error message.
It is up to the user to cancel out of this.
Hope this helps.
I am capturing Isdelete event.. and i can check for prospect but.. what should i do the display the error on the screen?
If(Trigger.IsDelete)
{
// The Delete Trigger will Only be triggered from the GUI when a user clicks on Delete
System.debug('Its here');
Account[] oldval = Trigger.old;
If (oldval[0].Prospect__C = True)
{
System.Debug('Test');
}
This is my Isdelete part of my trigger.
Thanks in advance
Trigger.new[0].addError("can't delete prospects");
In my case, I would like to prevent a user from deleting a Contact record based on certain logic.
However, instead of outputting an error message, I would like to update a record ownership, and not show the error to the user.
In short, can I prevent deletion without throwing an error?