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
Gullu SfGullu Sf 

Cannot Read Property 'setParams' of undefined

Hi There! I'm using standard events to create, edit, navigate and delete functionality. The Create, Edit and Navigate functions are working perfectly but when I come to deleting the record, I get an error saying cannot read property 'setParams' of Undefined. Can anyone tell me why it is throwing this error. I dont understand why its not working for delete. below is the js function for delete. I've printed out the recordId when I click on delete button and it is showing the correct recordId. If this is not working then I might have to pass the recordId to apex controller and delete it in a method, But I wanted to use the Salesforce Standard Event for Deleting the record as well. 
Thanks

DeleteRelation : function(component, event, helper){
        
        //Calling the Salesforce defined Standard Event for deleting Record.
        var ACRId = event.currentTarget.dataset.value;
        console.log("deleterecord"+ACRId);
        //Calling the EditRecord Event.
        var deleteEvent = $A.get("e.force:deleteRecord");
        //Setting the Params for the deleteEvent Action.
        deleteEvent.setParams({
            entityApiName : "AccountContactRelation",
            recordId : ACRId 
        });
        //Firing the Event.
        deleteEvent.fire();
        
    },   
Maharajan CMaharajan C
Hi,

You are missing the double quotes in the setParams.

It should be like below:

deleteEvent.setParams({
            "entityApiName" : "AccountContactRelation",
            "recordId" : ACRId 
        });


Can you please Let me know if it helps or not!!!

If it helps don't forget to mark this as a best answer!!!


Thanks,
Raj
 
Gullu SfGullu Sf
Hey Maharajan, I dont think we should use " " for the parameters. Because for Create, Edit and Navigate I haven't used double quotes. Below is my JS function for Editing the record and it works.

//This Function is used to invoke the editRecord Event on click of Edit Button.
    EditRelation : function(component, event, helper){
        
        //Calling the Salesforce defined Standard Event for editing Record.
        var ACRId = event.currentTarget.dataset.value;
        //Calling the EditRecord Event.
        var editEvent = $A.get("e.force:editRecord");
        //Setting the Params for the Edit Record Action.
        editEvent.setParams({
            recordId : ACRId 
        });
        //Firing the Event.
        editEvent.fire();
        
    },
Maharajan CMaharajan C
Do you have tried changes as per my suggestion?

Is it work or not with the double quotes? 

 
Gullu SfGullu Sf
No Bro, It did not work out. Still I get the same error.
 
Gullu SfGullu Sf
Hey, I just checked out the developer guide, The event force:deleteEvent does not exist. Now the only option I have is to pass the recordId to the Apex controller and delete it using a method.