function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
MaxFrielMaxFriel 

Warning rather than error on trigger...

With in a trigger, I would like to flag a warning that does not prevent the DML operation but still notifies the user.  Is this possible at all?  Pretty much exactly like the addError method but still allowing the DML operation. 

colemabcolemab

It may not be quite what you want but you can simulate this by having a hidden flag field on the object in question.  Then the trigger can check that field.  If it isn't populated, display the error/warning and stop the DML action.

 

Then in your error message, you need to have a link that will override the error by setting the field and retrying the DML action.  Then when the trigger fires again, it will allow the DML.

 

I don't have any working code on this my self but I have seen it in other applications.

 

Hope this helps.   Please share any working examples you may create so that others can benfit.

thedabblerthedabbler

This can also be done in couple of other ways .One is overriding the Standard Delete button with a visual force page and a controller.

User clicks the delete button.Use some javascript to give warn in message like 'Are You really want to delete it?'

And then once they click Yes.call the delete DML operation.

If they say no redirect them back to Original record.

 

Other way you can completely avoide visual force page and just have apex class with a method for deleting. You can get rid of standard Delete button and create custom Delete  button. And you can call those class method from javascript Button click. You have to make use of salesforce ajax toolkit.The method has to be webservice method I think.You can always create custom button and put javascript there to alert with message and once they confirm you can call delete method.

 

 

 

 

 

 

 

RohRoh
Hello Max,
Why not try using a JS action on this button ?
Basically, try to throw a pop up confirmation .
Thats what i can think of for now.

PLEASE VOTE THIS AS THE BEST ANSWER,IF YOU LIKE IT.

Thanks,
Rohit Alladi
Ravi Dutt SharmaRavi Dutt Sharma
Hey Max,

You can create a boolean field on the object (default unchecked) and whenever you need to show the warning message, update this boolean field to true in your trigger. Now create an inline VF page which you need to insert in your detail page layout. This page will check the value of the boolean field, if the value is true, it will display the warning message and update the value back to false.