You need to sign in to do that
Don't have an account?
DML currently not allowed
Hello,
i think I have this time sth. interesting.
The error message is in the Subject and it results because of the following.
I have a list, lets call it SuperList. And in a function getSuperList I put it in a datatable.
But the function should do sth. else too.
This:
List<Obj__c> SuperRecords = new List<Obj__c> ();
for(Obj__c x : SuperList){
if(x.wasSuper__c == false) SuperRecords.add(i);
}
update SuperRecords;
wasSuper is a checkbox. And i want that every Record which has ever been in the SuperList gets the checkbox wasSuper to true. But i get that annoying Error Message.
I hope you can help me.
Are you calling getListName() inside constructor? DML operations are not allowed inside constructor. If you can post the code it will be useful for us to solve. In addition, try moving your DML operations to some other method, and call it in VF through <apex:page..... action="theNewmethod" >
All Answers
It seems like you're attempting to do this in the page constructor.
You cannot do inserts/updates/deletes/undeletes/anything else that does a DML operation in the page constructor.
I think what you can instead do is define an action in the <apex:page action="{!YourActionHere}"> attribute and do your logic there. You can do the stuff you wanted to do in the constructor there.
It is not in the page constructor. It is all in a function getListName() which i use tu return a list to a datatable.
Do you have an other solution?
Are you calling getListName() inside constructor? DML operations are not allowed inside constructor. If you can post the code it will be useful for us to solve. In addition, try moving your DML operations to some other method, and call it in VF through <apex:page..... action="theNewmethod" >
No, i am not calling getListName() in the constructor. The only time it is used, is and called is on my VF page in the value attribute of the apex:datatable.
In the action is already another function, can i use 2 of them?
I solved it with putting it in the action method...maybe it is not allowed to put dml actions in get-methods.