---
schema_version: "1"
id: 5b26dd5f22edb1e358b914e80c3199b45f774b093d09296f538dfabe23044f48
title: Deleting Records with Remote Objects
collection: developer
version: current
locale: en-us
portal_url: https://docs.salesforce.com/developer/current/en-us/platform/salesforce-pages-developers-guide/guides/pages/javascript/pages-remote-objects-using-delete.md
canonical_url: https://developer.salesforce.com/docs/platform/salesforce-pages-developers-guide/guide/pages-remote-objects-using-delete.html
source_site: developer.salesforce.com
content_type: documentation
content_hash: ffced5532149b898c4a2b15e511c8638eede9cb450c94f462479cfd4a17a15b6
products:
  - Visualforce Developer Guide
  - Platform Developer Content
---

# Deleting Records with Remote Objects

Delete records by calling `del()` on a Remote Objects model instance.

`del()` accepts two arguments, both optional, and can delete one or many records, depending on the arguments that you provide.

**note:** Why `del()` instead of `delete()`? `delete` is a reserved word in JavaScript.

```javascript
RemoteObjectModel.del([record_ids], callback_function)
```

`record_ids` is an array of strings, where the strings are the `Id`s of records to be deleted. If this parameter is omitted, the `Id` that is set on the Remote Object instance is used. The simplest way to delete a record is to call `del()` on itself.

```javascript
ctDetails = {FirstName: "Tobe", LastName: "Ornottobe"};
ct = new RemoteObjectModel.Contact(ctDetails);
ct.create();

// After some thought, and the async operation completes...
// It's not to be; delete the contact
ct.del();
```

More often, you might need to delete a record in response to a button click. Deleting the record is as simple as getting the record’s `Id` from the page and then passing the `Id` to `del()`. For example:

```javascript
var id = $jQuery('#contactId').val();
var ct = new RemoteObjectModel.Contact();
ct.del(id);

```

Robust code includes a callback to handle errors. The following code accomplishes the same as the previous sample, altered to use an event handler and a callback function.

```javascript
// Handle the delete button click
function deleteContact(e){
    e.preventDefault();
    var ct = new RemoteObjectModel.Contact();
    ct.del($jQuery('#contactId').val(), updateCallback);
}

// Callback to handle DML Remote Objects calls
function updateCallback(err, ids){
    if (err) { 
        displayError(err); 
    } else {
        // Reload the contacts with current list
        getAllContacts();
        $jQuery.mobile.changePage('#listpage', {changeHash: true});
    }
}

```

To delete multiple records in one request—for example, checked items from a list—pass an array of `Id`s to `del()`.

```javascript
var ct = new RemoteObjectModel.Contact();
ct.del(['003xxxxxxxxxxxxxxx', '003xxxxxxxxxxxxxxx'], function(err, ids) {
    if (err) { 
        displayError(err); 
    } else {
        // Reload the contacts with current list
        getAllContacts();
        $jQuery('#status').html(ids.length + ' record(s) deleted.');
        $jQuery.mobile.changePage('#listpage', {changeHash: true});
    }
});
```

**note:** When you delete multiple records this way, all of the records are deleted in the same server-side transaction.

**See Also**  


-   [Visualforce Remote Objects Callback Functions](https://developer.salesforce.com/docs/platform/salesforce-pages-developers-guide/guide/pages-remote-objects-callback-functions.md)

