[英]Dynamics CRM get selected entity's attribute value
I need to get an attribute value ("val_index") of an entity which is selected in lookup. 我需要获取在查找中选择的实体的属性值(“ val_index”)。
function onLookupChange(){
var entityName, entityId, entityLabel, lookupFieldObject;
lookupFieldObject = Xrm.Page.data.entity.attributes.get('my_attribute');
if (lookupFieldObject.getValue() != null) {
entityId = lookupFieldObject.getValue()[0].id;
entityName = lookupFieldObject.getValue()[0].entityType;
entityLabel = lookupFieldObject.getValue()[0].name;
}
// here I need to get an attribute value of a selected entity. Attribute's name is "val_index"
}
How can I do that? 我怎样才能做到这一点?
Use the SDK.REST.js
library which ships with the CRM SDK to do this. 使用CRM SDK附带的SDK.REST.js
库来执行此操作。 Include this as a script in your form entity and you can reference the functions to make REST calls. 将此作为脚本包含在表单实体中,您可以引用函数进行REST调用。
An example call might look like this: 一个示例调用可能如下所示:
// Assume we are working with the account entity.
// This call is asynchronous.
SDK.REST.retrieveRecord(entityId, "Account", "val_index", null,
// Success.
function (result) {
var value = result.val_index;
// Do something.
},
// Error retrieving the value.
function (error) {
// Notify the user...
});
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.