hi sfdcjoey DML operation is not allowed in the constructor of Apex class. Whenever we go for a DML operation in constructor it resticts us in Salesforce.Only DDL is allowed. its salesforce restiction but If you want to Perform DML then you have to write a function in class and call this functon by action attribute of <apex:page action="YOUR Funciton Name">
http://www.mindfiresolutions.com/DML-Operation-Salesforce-ApexA-Trick-To-Avoid-Problem-Of-DML-At-Constructor-1809.php Thanks Mark it best answer if it helps you so it make proper solution for other :)
Imagine that your users are loged in on salesforce. You have a visualforce like https://c.eu0.visual.force.com/apex/createTask If any of your users get into a external website that has something like
DML operation is not allowed in the constructor of Apex class.
Whenever we go for a DML operation in constructor it resticts us in Salesforce.Only DDL is allowed. its salesforce restiction
but If you want to Perform DML then you have to write a function in class and call this functon by action attribute of <apex:page action="YOUR Funciton Name">
There are some blog
http://salesforceworld4u.blogspot.in/2014/08/how-to-do-dml-operation-when-page-loads.html
http://www.mindfiresolutions.com/DML-Operation-Salesforce-ApexA-Trick-To-Avoid-Problem-Of-DML-At-Constructor-1809.php
Thanks
Mark it best answer if it helps you so it make proper solution for other :)
Easy,
Imagine that your users are loged in on salesforce.
It will actually trigger your dmls without the user even knowing that, which is risky businessYou have a visualforce like https://c.eu0.visual.force.com/apex/createTask
If any of your users get into a external website that has something like
Kind regards.