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.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s