So I have managed to get the object I want to delete through my method, however I am not sure how I would go about deleting it - I have spent the last thirty minutes going through the documentation and looking on here but just can't seem how to do it. So far I have this in my controller:

destroy : function(component, evt, helper) {
  var expense = component.get("v.expense");

I was wondering how I would destroy this instance.


I understand that I need more experience but I like to jump into things and find things out for myself plus it makes me research and read about a variety of things finding out the issue.

  • do you want to delete expense or the component itself. If the expense then [pass them in controller and perform DML. Jan 26, 2016 at 11:55
  • ah thank you I've seen my problem now I was trying to delete the expense
    – user26719
    Jan 26, 2016 at 11:57
  • Would you have any tips on how to do that by any chance? :)
    – user26719
    Jan 26, 2016 at 11:58

1 Answer 1


first pass this list in controller

destroy : function(component) {
    var action = component.get("c.dltexpense");

        expenseList  : component.get("v.expense");

    action.setCallback(this, function(a) {
        if (a.getState() === "SUCCESS") {
        } else if (a.getState() === "ERROR") {
            $A.log("Errors", a.getError());


Now in controller delete this records

    public static boolean dltexpense(List<expense__c> expenseList ) {
       delete expenseList;
       return true;

use this. It will solve your problem.

  • I've tried this and keep running into this issue: Cannot read property 'setParams' of undefined
    – user26719
    Jan 26, 2016 at 12:26
  • which line causing this error Jan 26, 2016 at 12:28
  • I believe it is this code here action.setParams({ expenseList : component.get("v.expense") });
    – user26719
    Jan 26, 2016 at 12:29
  • did you add controller in component. Also check if you are getting record in component.get("v.expense") Jan 26, 2016 at 12:36
  • Yeah I have a component already and I am getting the record as its being used in the same controller in a different method
    – user26719
    Jan 26, 2016 at 12:44

You must log in to answer this question.