function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Praveen Muddana 14Praveen 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
SwethaSwetha (Salesforce Developers) 
HI Praveen,
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:
<aura:component>
  <aura:attribute name="myRecord" type="Object" />
  <aura:handler name="init" value="{!this}" action="{!c.doInit}" />

  <lightning:button label="Save" onclick="{!c.saveRecord}" />
</aura:component>

In the controller file (e.g. myComponentController.js), create the doInit and saveRecord methods:
({
  doInit: function(component, event, helper) {
    var action = component.get("c.getRecord");
    action.setCallback(this, function(response) {
      var state = response.getState();
      if (state === "SUCCESS") {
        component.set("v.myRecord", response.getReturnValue());
      } else {
        console.log("Error retrieving record.");
      }
    });
    $A.enqueueAction(action);
  },

  saveRecord: function(component, event, helper) {
    var myRecord = component.get("v.myRecord");

    var action = component.get("c.updateRecord");
    action.setParams({ record: myRecord });
    action.setCallback(this, function(response) {
      var state = response.getState();
      if (state === "SUCCESS") {
        console.log("Record saved successfully.");
      } else {
        console.log("Error saving record.");
      }
    });
    $A.enqueueAction(action);
  }
})

In the server-side Apex controller (e.g. myController.cls), create the getRecord and updateRecord methods:
public class myController {
  @AuraEnabled
  public static Account getRecord() {
    return [SELECT Id, Name FROM Account LIMIT 1];
  }

  @AuraEnabled
  public static void updateRecord(Account record) {
    update record;
  }
}

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