Saturday, February 4, 2012

Delete Record Using oData Call

Problem:
              Need to delete record from Microsoft CRM 2011 by using the oData call in Microsoft CRM 2011.

Solution:
             The solution to delete record using oData call is similar to the what we have done in my last post "Update Record Using oData Call" where we use the current record Id to update the record here we use same code but with some modification to delete the current record. You can see the code in the List 1 , here you can see similar code which I have used for update of record in "Update Record Using oData Call" post with some modification. First I have only passed the record Id which is used for the delete purpose. Second is the X-HTTP-Method here I have passed DELETE as I am performing the delete operation for the passed GUID.

List 1

And the last modification in the code is the send method of the XMLHttpRequest, here I didn't pass any parameter.On successful deletion of the record it will return status of the 204 or 1223 same as used for the update. Above is the sample piece of code which is used to delete the record by using oData call.

All and any comments / bugs / suggestions are welcomed!

No comments: