REST – Delete Example

Delete:

Syntax: SDK.REST.deleteRecord(id, type, successCallback, errorCallback)

Name Type Description
id String A String representing the GUID value for the record to delete.
type String The Schema Name of the Entity type record to delete.For an Account record, use “Account”
successCallback Function The function that will be passed through and be called by a successful response.
Nothing will be returned to this function.
errorCallback Function The function that will be passed through and be called by a failed response.
This function must accept an Error object as a parameter.

Task: Delete an Existing Account using AccountId.

Solution: Add the below Script in “new_sdkOperations” Webresource and click Ok.

Please do check REST – Retrieve Example for Initial Setup

function deleteAccount() {
    if (confirm("Do you want to delete this account record?")) {
        alert("You chose to delete the account record.");
        SDK.REST.deleteRecord(
            "{312B24BA-7CC1-E311-AAEF-D89D67790688}", //Add Existing Account GUID
            "Account",
            function() {
                alert("The account was deleted.");
            },
            errorHandler
        );
    }
}

function errorHandler(error) {
    alert(error.message);
}

Add OnLoad event in Account Form, Library: new_sdkOperations &function deleteAccount. Save and Publish

REST - Delete Webresource

Output:

REST - Delete Output

Please provide your valuable comments on this article.