【发布时间】:2017-08-25 22:28:59
【问题描述】:
因此,我正在尝试为 Dynamics CRM 2016 中的功能区按钮编写 JavaScript 代码,该代码将从活动潜在客户窗口中可以看到的潜在客户列表中获取电话号码。
但是,当我尝试运行它时,我收到一个错误提示
当我进入我的代码时(我正在调试),我看到了这个错误
这是我正在使用的代码。
function updateSelected(SelectedControlSelectedItemIds, SelectedEntityTypeName) {
// this should iterate through the list
SelectedControlSelectedItemIds.forEach(
function (selected, index) {
//this should get the id and name of the selected lead
getPhoneNumber(selected, SelectedEntityTypeName);
});
}
//I should have the lead ID and Name here, but it is returning null
function getPhoneNumber(id, entityName) {
var query = "telephone1";
Sdk.WebApi.retrieveRecord(id, entityName, query, "",
function (result) {
var telephone1 = result.telephone1;
// I'm trying to capture the number and display it via alert.
alert(telephone1);
},
function (error) {
alert(error);
})
}
感谢任何帮助。
【问题讨论】:
-
您确定没有在 Ribbon Workbench 中混淆参数吗?我认为您只是选择了实体名称作为第一个参数,并选择了 ids 作为第二个参数。应该很容易调试——SelectedControlSelectedItemIds 是什么类型?
-
我相信 SelectedControlSelectedItemIds 是一个字符串。
-
如果它是一个字符串,那么你一定是混淆了你的参数
-
好的,那么工作台中的CRM Parameter顺序应该是:SelectedControlSelectedItedIDs和PrimaryEntityTypeNeame?
-
您不能简单地调试代码并检查其中的值吗?这确实是编程的基础知识,一点也不难……您提出的问题让我 100% 确信您甚至没有设置一个断点来检查代码中到底发生了什么。