检索实体记录。
Syntax
Microsoft.CIFramework.retrieveRecord(entityLogicalName, id, options).then(successCallback, errorCallback);
参数
| Name | 类型 | 必选 | Description |
|---|---|---|---|
| 实体逻辑名称 | String | 是的 | 要检索的记录的实体逻辑名称。 例如:“帐户”。 |
| id | String | 是的 | 要检索的实体记录的 GUID。 |
| options | String | 否 | OData 系统查询选项 $select 和 $expand,用于检索数据。
指定以 开 ?$select=name&$expand=primarycontactid($select=contactid,fullname)
|
| success回调 | 功能 | 否 | 检索记录时要调用的函数。 |
| errorCallback | 功能 | 否 | 作失败时要调用的函数。 |
返回值
成功后,返回一个 promise,其中包含包含检索到的属性及其值的字符串。
例子
此示例代码检索 ID a8a19cdd-88df-e311-b8e5-6c3be5a8b200= 的联系人记录的姓名和电话号码。
// retrieve contact record
var id = "b44d31ac-5fd1-e811-8158-000d3af97055";
var entityLogicalName = "contact";
Microsoft.CIFramework.retrieveRecord(entityLogicalName, id, "?$select=fullname,telephone1").then(
function success(result) {
res=JSON.parse(result);
console.log(`Retrieved values: Full Name: ${res.fullname}, Telephone Number: ${res.telephone1}`);
// perform operations on record retrieval
},
function (error) {
console.log(error.message);
// handle error conditions
}
);