You need to sign in to do that
Don't have an account?
j_r_ro
DML currrently not allowed in method called from a constructor
Hi all,
I am trying to perform a DML operation in a method that is called by the page controller constructor.
I know DML is not allowed in the constructor - is it also not allowed in any methods called by the constructor?
Since I am using an apex page, I can't use the 'allowDml' attribute. The other possible solution I found was to use an action on the page.
My page already has an action - can I have multiple actions on the page, or only one?
Are there any other ways to get around this?
Thanks.
you call other method inside the action method
<apex:page controller="Test123" action="{!Test}">
public class Test123 {
public string Test2() {
return 'ABC';
}
public PageReference Test() {
Test2();
return null;
}
}
If your method(which has a dml) is getting called from constructor then it equivalent ot doing a DML in the constructor itself.. and DMl as you know is not allowed in Constructor.