Salesforce | Visualforce | Error : DML currently not allowed exception on creation of the record on an Object

|
| By Webner

When creating a record on the document object using Rest API, Salesforce did not allow to execute the DML command from the Visualforce component.

Reason: When we try to pass dynamic values from the Visualforce Component to the Apex method, Salesforce does not allow us to put any DML operation on that data.

Solution: To overcome this error, you need to allow the DML operations from the component.
To do so, you need to set “ALLOW DML” Attribute in the component to true.

Example:

<apex:component Controller="DragAndDropMultipleDirect" allowDML="true" rendered = “true”>

Note: According to Salesforce documentation when allowing DML within a component, you should include render attributes so that consumer can appropriately refresh their page. In addition, mention in detail in the description of the component about which data is manipulated by the DML so that consumers of the component are aware of potential side-effects.

Leave a Reply

Your email address will not be published. Required fields are marked *