我创建.js代码时似乎无法让我的Xrm变量工作。我需要包含一个库还是需要首先运行的函数?我是否需要确保ClientGlobalContext.js.aspx被正确引用?我处于'C++'的心态,只是想知道是否有任何需要运行的'include'命令。Xrm在Dynamics CRM 2011中未定义
我的js文件看起来像这样,如果我删除'window.parent。'从第二个函数中,如果我打电话,代码就会中断。
///<reference path="C:\Users\steve.lee\Downloads\XrmPage-vsdoc.js"/>
if (typeof (SDK) == "undefined")
{ SDK = { __namespace: true }; }
SDK.XRM = {
getCurrentControl: function() {
var currentControl = Xrm.Page.ui.getCurrentControl();
if (currentControl == null) {
alert("No controls currently have focus.");
}
else {
alert("The control for the '" + currentControl.getLabel() + "' attribute currently has focus.");
}
},
getCurrentGUID: function() {
if (window.parent.Xrm.Page.data.entity != null) {
var GUIDvalue = window.parent.Xrm.Page.data.entity.getId();
if (GUIDvalue != null) {
return GUIDvalue;
}
else {
return null;
}
}
else {
return null;
}
},
__namespace: true
};
请添加代码示例或描述特定的错误。 – ccellar
错误是一个通用的JavaScript弹出,其中说'Xrm.Page.data.entity'为空或不是对象 – Steve