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
Priyanka BardhanPriyanka Bardhan 

How to perform dml in VF component used by Visualforce email template via workflow email alert?

DML can be done using attribute allowDML="true" to component.
But as per my understanding, DML can't be done for below cases:
  • You can't use data manipulation language (DML) operations in a “getxxx” method in a controller.
  • You can't use data manipulation language (DML) operations in a constructor method in a controller.
  • You can't use the @future annotation in a “getxxx” or “setxxx” method in a controller, or in the constructor for a controller.

Question: Whether Visualforce email templates allow you to include visualforce components with allowDML="true" and is there any way to actually do DML in case of any error scenario? My requirement is do insert error logs in case of any errors happened /blank PDF generated?

Thanks & Regards,
Priyanka Bardhan