When i am adding header component to new visual force page then it is returning exception saying

Visualforce Error

System.LimitException: DML currently not allowed

Class.ExceptionManager.save: line 14, column 1
Class.ExceptionService.saveException: line 25, column 1
Class.BaseController.<init>: line 348, column 1
Class.SignUpController.<init>: line 79, column 1

How do i get a solution for this problem ?

<apex:page showHeader="false" controller="RequestTradeController" standardStylesheets="false" >
        document.title = '{!$Label.lblCR} - New Trade Relationship';
    <c:CommonComponent />
    <apex:form >
        <h2>Request New Trade Relationship</h2>

        <table width="70%">
            <tr><td><apex:pageMessage severity="warning">Select how you would like to send your request.</apex:pageMessage>    </td></tr>
            <tr><td align="center" class="button_link bgcolor-tab"><apex:commandButton styleClass="button_style button_link" action="{!test}" value="Request New Relationship using the Seller's CashRelease ID" id="theButton1"/></td></tr>
            <tr><td align="center"><b>OR</b></td></tr>
            <tr><td align="center" class="button_link bgcolor-tab"><apex:commandButton styleClass="button_style button_link" action="{!redirectToNewTrade}" value="Request New Relationship by Sending an Email Invitation to the Seller" id="theButton2"/></td></tr>


In this is already allowing the DML. so why i am getting this error?


You need to set the allowDML attribute of your component to true for DML to be allowed by your component. Take a look at the documentation on apex:component.

For example:


<apex:component controller="MyComponentController" allowDML="true">
      <apex:commandButton value="Execute DML" action="{!executeDML}"/>

Component Controller

public with sharing class MyComponentController {

     public PageReference executeDML() {
         Account a = new Account(Name = 'Test');
         insert a;

         return null;


<apex:page >
    <c:myComponent />

From the apex:component documentation on allowDML:

If this attribute is set to "true", you can include DML within the component. The default is "false". Allowing DML can cause side-effects that could be problematic for consumers using the component with partial page updates. When allowing DML within a component, you should include rerender attributes so the consumer can appropriately refresh their page. In addition, you should detail, in the description of the component, what data is manipulated by the DML so that consumers of the component are aware of potential side-effects.

It is also possible that the error is being caused because there is DML in a constructor which is not allowed.

It appears that the Exception is originating in your SignUpController (Class.SignUpController.: line 79, column 1) which is not the page's controller. I'd start with looking at that.

  • please see the code, then tell me why i getting this error? Apr 8 '14 at 9:45
  • Thanks for posting some of your code. I updated my answer with another possibility and a suggestion. Apr 8 '14 at 10:10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.