You need to sign in to do that
Don't have an account?
Suman Kundu
System.LimitException: DML currently not allowed - from Approval.process method
I am using an extension class where for some condition, an approval is processed from constructor. There is no DML operation previously used in that constructor. In the VF page, I am using a component. To avoid this error I have also used attribute allowDML="true" in the component tag. But it doesn't help at all.
Please help me.
Hi,
You can’t use DML operation inside the constructor. So simply create a function and call that function inside the constructor of your class and inside that function you can use the DML(inset,update,delete) operation. Try the below code as reference:
Public class test
{
List<contact> con{get;set;}
Public test()
{
Show()
}
Public void show()
{
Con=[select id,lastname from contact limit 1000];
Update con;
}
}
Did this answer your question? If not, let me know what didn't work, or if so, please mark it solved.
You can not directly or indirectly perform DML in constructor. There is an attribute called action on apex:page tag. You need to assign your controller's public method's name here. Then the action it will be performed in your page load.
Thanks
Vishnu
The error obviously occurs in standard visualforce action methods, too. Consider the following example of one of our visualforce components:
(Please see below for the error log)
The method is simply envoked by using a commandButton in a visualforce component. Independently if you use reRender attribute or simple page reload, the error is not displayed as error message, in one case, the user is redirected to a page showing the component only (in fullscreen), another result is a page that "does not exist anymore". Well known debugging hell.
Any ideas? Thank you very much in advance and
best regards
JOhannes
15:07:24.081 (81105000)|CODE_UNIT_STARTED|[EXTERNAL]|01pR00000001e51|cmSelectPublicGroupController invoke(submitRequestAction)
15:07:24.081 (81160000)|SYSTEM_MODE_ENTER|false
15:07:24.081 (81186000)|METHOD_ENTRY|[168]|01pR00000001e51|cmSelectPublicGroupController.__sfdc_subjectId()
15:07:24.081 (81221000)|METHOD_EXIT|[168]|01pR00000001e51|cmSelectPublicGroupController.__sfdc_subjectId()
15:07:24.081 (81253000)|SYSTEM_METHOD_ENTRY|[168]|System.assertNotEquals(ANY, ANY, ANY)
15:07:24.081 (81280000)|SYSTEM_METHOD_EXIT|[168]|System.assertNotEquals(ANY, ANY, ANY)
15:07:24.081 (81292000)|METHOD_ENTRY|[170]|01pR00000001e51|cmSelectPublicGroupController.__sfdc_selectedGroupMember()
15:07:24.081 (81311000)|METHOD_EXIT|[170]|01pR00000001e51|cmSelectPublicGroupController.__sfdc_selectedGroupMember()
15:07:24.081 (81336000)|SYSTEM_METHOD_ENTRY|[170]|System.assertNotEquals(ANY, ANY, ANY)
15:07:24.081 (81354000)|SYSTEM_METHOD_EXIT|[170]|System.assertNotEquals(ANY, ANY, ANY)
15:07:24.081 (81362000)|METHOD_ENTRY|[172]|01pR00000001e51|cmSelectPublicGroupController.__sfdc_subjectId()
15:07:24.081 (81382000)|METHOD_EXIT|[172]|01pR00000001e51|cmSelectPublicGroupController.__sfdc_subjectId()
15:07:24.081 (81391000)|METHOD_ENTRY|[172]|01pR00000001e51|cmSelectPublicGroupController.__sfdc_selectedGroupMember()
15:07:24.081 (81400000)|METHOD_EXIT|[172]|01pR00000001e51|cmSelectPublicGroupController.__sfdc_selectedGroupMember()
15:07:24.081 (81662000)|METHOD_ENTRY|[176]|01pR00000001e51|cmSelectPublicGroupController.__sfdc_approvalRequestComment()
15:07:24.081 (81696000)|METHOD_EXIT|[176]|01pR00000001e51|cmSelectPublicGroupController.__sfdc_approvalRequestComment()
15:07:24.081 (81747000)|METHOD_ENTRY|[178]|01pR00000001e51|cmSelectPublicGroupController.__sfdc_subjectId()
15:07:24.081 (81769000)|METHOD_EXIT|[178]|01pR00000001e51|cmSelectPublicGroupController.__sfdc_subjectId()
15:07:24.081 (81826000)|SYSTEM_METHOD_ENTRY|[182]|Approval.process(Approval.ProcessRequest)
15:07:24.081 (81885000)|DML_BEGIN|[182]|Op:Process|Type:ProcessRequest|Rows:1
15:07:24.081 (81911000)|EXCEPTION_THROWN|[182]|System.LimitException: DML currently not allowed
15:07:24.082 (82031000)|SYSTEM_METHOD_EXIT|[182]|Approval.process(Approval.ProcessRequest)
15:07:24.082 (82072000)|SYSTEM_MODE_EXIT|false
15:07:24.082 (82143000)|FATAL_ERROR|System.LimitException: DML currently not allowed
Class.cmSelectPublicGroupController.submitRequestAction: line 182, column 1
15:07:24.082 (82152000)|CODE_UNIT_FINISHED|cmSelectPublicGroupController invoke(submitRequestAction)
15:07:24.821 (207669000)|CUMULATIVE_LIMIT_USAGE
15:07:24.821|LIMIT_USAGE_FOR_NS|(default)|
Number of SOQL queries: 0 out of 100
Number of query rows: 0 out of 50000
Number of SOSL queries: 0 out of 20
Number of DML statements: 0 out of 150
Number of DML rows: 0 out of 10000
Number of script statements: 19 out of 200000
Maximum heap size: 0 out of 6000000
Number of callouts: 0 out of 10
Number of Email Invocations: 0 out of 10
Number of fields describes: 0 out of 100
Number of record type describes: 0 out of 100
Number of child relationships describes: 0 out of 100
Number of picklist describes: 0 out of 100
Number of future calls: 0 out of 10
15:07:24.821|CUMULATIVE_LIMIT_USAGE_END
15:07:24.207 (207720000)|CODE_UNIT_FINISHED|VF: /apex/scOrderGroupApproval
15:07:24.207 (207735000)|EXECUTION_FINISHED
Ok, i must confess -- using the "allowDml"-Attribute in the component definition actually solves the problem. Heureka!