Dynamics 365 v9.0: Xrm.WebApi – CRUD Operations Part – 1

By | January 29, 2018

Introduction:

Microsoft Dynamics 365 July Update, formally known as V9.0 has come up with lots of new and exciting features. No doubt these features have been applauded by end users and developers.

One of the important enhancement that will be boon for developer is Xrm.WebApi. Earlier to v9.0, to perform CRUD operation in Dynamics CRM we need to create our own library or used other third party libraries or used XmlHttpRequest and ajax request. So Xrm.WebApi is a cool enhancement added in Dynamics 365 v9.0 which will help to make developers life simple.

In this blog, we will discuss about how we can perform CRUD operations and work with all data types using newly added WebApi in Xrm namespace.

Using Xrm.WebApi:

Below is the example where we can used Xrm.WebApi.

1. Create:

To create the record, first we need to create the object of entity and then set the required fields and its value and then call Xrm.WebApi.createRecord function to create record in CRM. The parameters of this function are shown below;

1. Entity logical name

2. Entity object

 2. Update:

To update the record, first we need to create the object of the entity and then set the fields and its value that we need to update and then call Xrm.WebApi.updateRecord function to create the record in CRM. The parameters of this function are as shown below;

1. Entity logical name

2. Entity guid

3. Entity object

3. Delete:

To delete record from CRM use Xrm.WebApi.deleteRecord.

 The parameters of this function are shown below;

1. Entity logical name

2. Entity guid

4. Retrieve Record:

In order to retrieve record we can use Xrm.WebApi.retrieveRecord. The parameters of this function are as shown below;

1. Entity logical name

2. Entity guid

3. In last parameter pass following [select cause, filter cause etc.]

 

Note: If you want to get the value of lookup field you have use _ as prefix and _value as suffix. For example for parentcustomerid use _parentcustomerid_value

 Conclusion:

Using Xrm.WebApi in Dynamics 365 v9.0, it is easy to perform CURD operation without performing AJAX request or creating own library or using third party libraries.

Copy System and Custom Entities in Dynamics CRM

Leave a Reply

Your email address will not be published. Required fields are marked *