Sunday 24 September 2017

DML not allowed in Constructor in Salesforce


Salesforce has blocked this due to security issues. If you want to do DML operation during VF page loading, use action attrirbute in <apex:page>. Call a method from the action in which DML operation is allowed.


Special Note:
https://salesforce.stackexchange.com/questions/28833/why-is-dml-not-allowed-in-constructor