You need to sign in to do that
Don't have an account?
Jerun Jose
Writing error messages to custom object
Hi,
I am using a trigger to show error messages. The requirement is to write the error event into an error object whenever the error occurs.
The problem I am having is that whenever I throw an error message, that transaction is treated as an exception and any writes to the DB in that transaction are rolled back.
So, the debug logs show one record is inserted, but I guess that is then rolled back. Any ideas on how we can achieve this ?
Thanks,
Jerun Jose
Not sure if I understand you correctly, but it sees like maybe you need to create a custom field on the object called "Error" and then instead of
you would do
?
Thanks for the response.
We are working on an integration project. The error generated needs to be returned to the invoking webservice. So I will have to use the addError method.
Thanks,
Jerun Jose
There was a similar question to this several days ago....
Basically anything you do via DML will get rolled back when you add the error....
I would suggest creating an @future method to write the error to an object. That way you can still throw the error and write it to another object via async @future.
Thanks again for the response.
I actually tried the future call route, but I am not sure if the future method got invoked at all.
The debug log shows:
Number of future calls : 1 of 10
But the apex jobs page does not show anything. Also, the DML in the future method did not seem to have happened as I could not find any new records.
If a transaction hits an exception, will the future callouts made also be rolled back?
Not sure, I was curious as to that myself....
If a transaction hits an exception, will the future callouts made also be rolled back?
I would imagine no because once it hits the @future method it becomes asynchronous. But I can't be sure... until I test that.