gpt4 book ai didi

javascript - CRM 2016 自动完成

转载 作者:行者123 更新时间:2023-11-29 19:15:47 26 4
gpt4 key购买 nike

我目前正在尝试在 CRM 在线 2016 环境中实现新 CRM 的自动完成功能。

我使用了 Sample: Auto-complete in CRM controls 中的代码并已验证它适用于帐户表单和另一个已存在的自定义实体。但是,当我使用它 1 个特定的自定义实体及其任何字符串字段时,不会出现自动完成框。

尝试:

  • 创建新表单
  • 为自动完成运行创建一个全新的文本字段
  • 已验证它正在命中 ext.getEventSource().showAutoComplete(resultSet);
  • 已验证我的 JS 没有抛出任何错误

任何人都知道什么可能是错误的?我认为它与我的实体或实体表单有关,而不是与代码或文本字段有关。

 /** Sample JavaScript code to demonstrate the auto-completion feature.
This sample configures the auto-complete feature for the "Account Name"
field in the account form. */

function suggestAccounts() {
// List of sample account names to suggest
accounts = [
{ name: 'A. Datum Corporation', code: 'A01' },
{ name: 'Adventure Works Cycles', code: 'A02' },
{ name: 'Alpine Ski House', code: 'A03' },
{ name: 'Bellows College', code: 'A04' },
{ name: 'Best For You Organics Company', code: 'A05' },
{ name: 'Blue Yonder Airlines', code: 'A06' },
{ name: 'City Power & Light', code: 'A07' },
{ name: 'Coho Vineyard', code: 'A08' },
{ name: 'Coho Winery', code: 'A09' },
{ name: 'Coho Vineyard & Winery', code: 'A10' },
{ name: 'Contoso, Ltd.', code: 'A11' },
{ name: 'Contoso Pharmaceuticals', code: 'A12' },
{ name: 'Contoso Suites', code: 'A13' },
{ name: 'Consolidated Messenger', code: 'A14' },
{ name: '​Fabrikam, Inc.', code: 'A15' },
{ name: 'Fabrikam Residences', code: 'A16' },
{ name: '​First Up Consultants', code: 'A17' },
{ name: 'Fourth Coffee', code: 'A18' },
{ name: 'Graphic Design Institute', code: 'A19' },
{ name: 'Humongous Insurance', code: 'A20' },
{ name: 'Lamna Healthcare Company', code: 'A21' },
{ name: 'Litware, Inc.', code: 'A22' },
{ name: 'Liberty Delightful Sinful Bakery & Cafe', code: 'A23' },
{ name: 'Lucerne Publishing', code: 'A24' },
{ name: 'Margie Travel', code: 'A25' },
{ name: '​Munson Pickles and Preserves Farm', code: 'A26' },
{ name: 'Nod Publishers', code: 'A27' },
{ name: 'Northwind Electric Cars', code: 'A28' },
{ name: 'Northwind Traders', code: 'A29' },
{ name: 'Proseware, Inc.', code: 'A30' },
{ name: 'Relecloud', code: 'A31' },
{ name: 'School of Fine Art', code: 'A32' },
{ name: 'Southridge Video', code: 'A33' },
{ name: 'Tailspin Toys', code: 'A34' },
{ name: 'Trey Research', code: 'A35' },
{ name: 'The Phone Company', code: 'A36' },
{ name: 'VanArsdel, Ltd.', code: 'A37' },
{ name: 'Wide World Importers', code: 'A38' },
{ name: '​Wingtip Toys', code: 'A39' },
{ name: 'Woodgrove Bank', code: 'A40' }
];

var keyPressFcn = function (ext) {
try {
var userInput = Xrm.Page.getControl("name").getValue();
resultSet = {
results: new Array(),
commands: {
id: "sp_commands",
label: "Learn More",
action: function () {
// Specify what you want to do when the user
// clicks the "Learn More" link at the bottom
// of the auto-completion list.
// For this sample, we are just opening a page
// that provides information on working with
// accounts in CRM.
window.open("http://www.microsoft.com/en-us/dynamics/crm-customer-center/create-or-edit-an-account.aspx");
}
}
};

var userInputLowerCase = userInput.toLowerCase();
for (i = 0; i < accounts.length; i++) {
if (userInputLowerCase === accounts[i].name.substring(0, userInputLowerCase.length).toLowerCase()) {
resultSet.results.push({
id: i,
fields: [accounts[i].name]
});
}
if (resultSet.results.length >= 10) break;
}

if (resultSet.results.length > 0) {
ext.getEventSource().showAutoComplete(resultSet);
} else {
ext.getEventSource().hideAutoComplete();
}
} catch (e) {
// Handle any exceptions. In the sample code,
// we are just displaying the exception, if any.
console.log(e);
}
};

Xrm.Page.getControl("name").addOnKeyPress(keyPressFcn);
}

最佳答案

您必须在表单上有一个查找控件才能呈现自动完成功能。这听起来很奇怪,但这是目前最好的解决方法。我设置我的不可见。注意:这是任何查找字段,与您选择的关系无关。让查找字段在表单上设置一些内容以加载缺少的库。

我周末的大部分时间都在试图找出类似的情况。我可以详细描述导致这一发现的事件,但我会饶过你。

我认为 Microsoft 正试图不包含他们看不到已配置需求的资源,这就是后端自动完成文件丢失的原因(直到您为它们添加要求)。

关于javascript - CRM 2016 自动完成,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35469720/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com