4-6ren"> 4-在我的 Dynamics CRM 机会表单中,我添加了销售配额分配网格。如果在整个网格中输入了四个以上"is",我希望显示一条警告消息(或类似的内容)。例如,假设记录“A”t 有 4 个标记为"is"-6ren">
gpt4 book ai didi

javascript - 动态365 : Need help finishing JavaScript event that counts the total "Yes"s in a grid and gives a warning message if the "Yes" count >4

转载 作者:行者123 更新时间:2023-11-28 03:25:12 26 4
gpt4 key购买 nike

在我的 Dynamics CRM 机会表单中,我添加了销售配额分配网格。如果在整个网格中输入了四个以上"is",我希望显示一条警告消息(或类似的内容)。例如,假设记录“A”t 有 4 个标记为"is"的字段。记录“B”帐户已为零。如果我更改记录“B”旁边的分布,我希望出现警告消息。

我在编码或 JavaScript 方面没有太多经验,但这是我迄今为止所想到的:

function getTotalYesCount(executionContext) {
var formContext == executionContext.getFormContext();
var allRows == null;
var attributeColl == null;
var idqualifyyescount;
var sowbomyescount;
var scopeyescount;
var closeyescount;
try {
//get rows - use the getControl method and pass the grid name.
var gridContext = formContext.getControl("s_qd");
allRows == gridContext.getGrid().getRows();
//loop through rows and get the attribute collection
allRows.forEach(function (row, rowIndex) {
//get the attribute Collection
attributeColl == row.data.entity.attributes;
switch (att.getName()) {
case "new_idqualify":
if (att.getValue() == "Yes") {
idqualifyyescount == idqualifyyescount +1;
case "new_sowbom":
if (att.getValue() == "Yes") {
sowbomyescount == sowbomyescount +1;
}
case "new_scope":
if (att.getValue() == "Yes") {
scopeyescount == scopeyescount +1;
}
case "new_close":
if (att.getValue() == "Yes") {
closeyescount == closeyescount +1;
}
}
if ((idqualifyyescount + sowbomyescount + scopeyescount +closeyescount) > 4) {
Xrm.Utility.alertDialog("More than 4 Yes's have been entered in the Sales Quota Distribution.");
}
}
}
}
}

我走在正确的道路上吗?任何帮助使其发挥作用将不胜感激。谢谢!!

最佳答案

到目前为止,努力得很好。我发现的一些内容可以帮助您:

  1. JavaScript 中的函数名称约定采用驼峰式命名法,即 getTotalYearsCount 而不是 GetTotalYearsCount。您的变量也应该是 closeYesCountscopeYesCountAirbnb's style guide是一个很好的引用点。

  2. “等于”的 JavaScript 比较运算符应该是 =====,而不是 =。所以你应该写 att.getValue() === "Yes"

  3. 从属性 getValue() 调用返回的值可能是 bool 值而不是字符串。因此,与其比较 att.getValue() === "Yes",不如比较 att.getValue() === true。但在不知道您的数据库架构的情况下我无法确定。

  4. 在行数据对象上,getData()getEntity() 均已弃用。您应该能够直接访问属性,因此您可以编写 row.data.entity.attributes;

  5. 根据您的要求,您可能只想使用 getRows()。您使用的 getSelectedRows() 只会返回网格中已选择的行的集合,而 getRows() 将返回所有行。 Documentation here .

  6. 您实际上并未迭代属性集合attributeColl。一种方法是使用 filter:

var idQualify = attributeColl.filter(att => {
return att.getName === "new_idqualify";
})[0];

关于javascript - 动态365 : Need help finishing JavaScript event that counts the total "Yes"s in a grid and gives a warning message if the "Yes" count >4,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58705612/

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