更新实体记录。
Syntax
microsoft-ciframework.updateRecord(entityLogicalName, id, data).then(successCallback, errorCallback);
参数
| Name | 类型 | 必选 | Description |
|---|---|---|---|
| 实体逻辑名称 | String | 是的 | 要更新的记录的实体逻辑名称。 例如:“帐户”。 |
| id | String | 是的 | 要更新的实体记录的 GUID。 |
| 数据 | String | 是的 | 包含 请参阅本主题后面的示例,了解如何定义 |
| success回调 | 功能 | 否 | 更新记录时要调用的函数。 |
| errorCallback | 功能 | 否 | 作失败时要调用的函数。 |
返回值
成功后,返回一个 promise,其中包含一个字符串,其中包含更新的属性及其值。
例子
此示例代码更新记录 ID = a8a19cdd-88df-e311-b8e5-6c3be5a8b200 的现有联系人记录
//// define the data to update a record
var entityLogicalName = "contact";
var data = {
"firstname": "Updated Sample",
"lastname": "Contact",
"fullname": "Updated Sample Contact",
"emailaddress1": "contact@contoso.com",
"jobtitle": "Sr. Marketing Manager",
"telephone1": "555-0109",
"description": "Updated values for this record were set programmatically."
}
// update contact record
var id = "b44d31ac-5fd1-e811-8158-000d3af97055";
var jsonData = JSON.stringify(data);
Microsoft.CIFramework.updateRecord(entityLogicalName,id,jsonData).then(
function success (result) {
res=JSON.parse(result);
console.log("Contact updated with ID: " + res.id);
//the record is updated
},
function (error) {
console.log(error);
//handle error conditions
}
);