Updates for Web API in Dynamics 365 in version 9.0 (1)

In version 9.0, we don’t need to create any request for using Web API, instead, we will use built-in and pre-defined functions for using Web API. Now Dynamics 365 has a new library Xrm.WebApi and performs CRUD using Web API.

Create an entity record
Check Microsoft URL:

function createContact() {
// define the data to create new contact
//var entity =
//    {
//      "firstname": "Max",
//      "lastname": "Liu",
//      "telephone1": "604-123456",
//      "address1_city": "Vancouver"
//    }
//contact data object
var entity={};
entity.firstname = "Max";
entity.lastname =  "Liu";
entity.telephone1 = "604-123456";
entity.address1_city="Vancouver";
//create record
Xrm.WebApi.createRecord("contact", entity).then (
function success(result){
	alert("Contact Created !!" + result.id); 
	// perform operations on record creation
 },
function (error) {
	alert(error.message);  
	 // handle error conditions
	}	
);
}

Update an entity record
Check Microsoft URL

function updateContact() {
//contact data object
var entity={};
entity.emailaddress1="max@gmail.com";
//get contact id
var contactId="5531d753-95af-e711-a94e-000d3a11e605";
Xrm.WebApi.updateRecord("contact",contactId,entity).then(
function success(result) {
	alert("Contact updated !!"); 
	// perform operations on record update
},
function (error) {
	alert(error.message);  
	 // handle error conditions
}
);
}

Delete an entity record
Check Microsoft URL

function deleteContact() {
//get contact id
var contactId="5531d753-95af-e711-a94e-000d3a11e605";
Xrm.WebApi.deleteRecord("contact",contactId).then(
function success(result) {
	alert("Contact deleted !!"); 
	// perform operations on record update
},
function (error) {
	alert(error.message);  
	 // handle error conditions
}
);
}
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值