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
S Balaji 8S Balaji 8 

Can someone help me why i am getting the below error please?

Class.Mod_LogEngagementDetailsController.createTaskRec: line 142, column 1
19:51:58.783 (4784549213)|FATAL_ERROR|System.DmlException: Insert failed. First exception on row 0; first error: UNABLE_TO_LOCK_ROW, unable to obtain exclusive access to this record or 1 records: 0018K000008YcEuQAK: []
========================================

@auraEnabled
    public static void createTaskRec(String objTask, String accId){
        Task objTsk = (Task)JSON.deserialize(objTask, Task.Class);
        if(!String.isBlank(accId) && (!String.isBlank(objTsk.description) || !String.isBlank(objTsk.OwnerId) || objTsk.ActivityDate != null)){
            Task objTaskNew= createTaskGen(objTsk.description, objTsk.OwnerId, objTsk.ActivityDate, accId);
            if(objTaskNew != null && Schema.sObjectType.Task.isUpdateable()){
                insert objTaskNew;
            }
        }
    }


Regards,
Balaji
AnkaiahAnkaiah (Salesforce Developers) 
Hi Balaji,

Refer the below link have solution for similar kind of issue.
https://developer.salesforce.com/forums/?id=9060G000000I2r1QAC

Thanks!!