You need to sign in to do that
Don't have an account?
Praveen Muddana 14
Application perform DML operations as a result of page action. As a security best practices, do not perform any DML operations automatically as a result of page load
How to avoid DML operations in server call methods (apex) from doinit of aura components calling them. is there workaround to fix the problem.if yes, please provide with an example
I'd suggest you avoid DML operations in server call methods (Apex) from the doinit method of Aura components. This is because the doinit method is called before the component is rendered, so any DML operations in that method could cause the page to be slow or unresponsive.
You could move the DML operations to a separate server call method that is called after the component is rendered. This way, the DML operations won't affect the rendering of the component.
Sample code:
In the component's markup file (e.g. myComponent.cmp), create a button or other user action that calls the server method:
In the controller file (e.g. myComponentController.js), create the doInit and saveRecord methods:
In the server-side Apex controller (e.g. myController.cls), create the getRecord and updateRecord methods:
Related: https://salesforce.stackexchange.com/questions/131628/lightning-security-on-init-page-load-with-server-side-call
If this information helps, please mark the answer as best. Thank you