Sage CRM

Using SData 2.0 in Sage CRM: Part 4 - Deleting records

Post Image

Welcome to the fourth installment of our SData 2.0 series, where we explore the powerful capabilities of Sage CRM’s SData 2.0 API. If you haven't already, check out Part 1, Part 2, and Part 3 to get up to speed with querying, updating, and inserting records using the API.

In this article, we’ll focus on deleting records—a crucial aspect of data manipulation enabled by SData 2.0. Using RESTful DELETE operations, you can effectively remove data from your Sage CRM database.

Syntax of a DELETE Operation

Deleting records in Sage CRM using SData 2.0 follows a straightforward syntax, similar to querying records, but with the DELETE verb in the REST call.

Key points to remember:

  • The URL must contain the ID of the record you wish to delete.
  • Upon successful deletion, the response will be empty, signaling that the record has been removed.

Example 1: Deleting a Company Record

Let’s begin by deleting a company record from Sage CRM. Suppose we need to delete the company with an ID of 1224.

Request:

DELETE http://{ServerName}/sdata/{InstallName}j/sagecrm2/-/Company('1224')



By sending this request via Postman or a similar tool, you should receive a blank response, indicating that the company record has been successfully deleted.

Response:

(no content)



The empty response confirms that the record has been successfully deleted from the system.

Example 2: Deleting an Email Address Associated with a Company

In this example, we will delete an email address associated with a specific company. To delete the email address, we first need to query the company to retrieve the Email ID.

Step 1: Query the Company’s Email Address

To get the email address associated with company 1225, send the following request to retrieve the relevant details:

GET http://{ServerName}/sdata/{InstallName}j/sagecrm2/-/Company('1225')



The response will include the ID of the associated email record. Let’s assume the Email ID is 2111.

Step 2: Delete the Email Record

Now, we can delete the email record using the DELETE method and the Email ID retrieved earlier:

DELETE http://{ServerName}/sdata/{InstallName}j/sagecrm2/-/Email('2111')



Once you send this request, the response will be blank, indicating the email record has been successfully deleted.

Response:

(no content)



Conclusion

The DELETE functionality within SData 2.0 provides an efficient and powerful way to manage your Sage CRM data. Whether you're cleaning up outdated records or adjusting your database, the ability to delete records is an essential part of maintaining accurate and up-to-date information.

In the next post, we’ll dive deeper into even more advanced features of SData 2.0. If you have any questions or need further assistance, feel free to reach out!

Stay tuned for more insights in our SData 2.0 series.