javascript - JavaScript/Dynamics CRM:需要帮助完成 JavaScript 事件,该事件计算网格的“Id & Qualify”字段中的记录数 =“Yes”
问题描述
在我的机会表单中,我添加了一个“销售配额分配”实体可编辑网格。一个商机可以有多个销售配额分配记录。我正在处理一个 JavaScript 事件,该事件计算销售配额分配网格中显示的记录的“ID 和资格”字段中的记录数 =“是”。“ID & Qualify”是一个下拉字段,它包含的两个选项是“是”和“否”。我相信我即将完成,但由于某种原因代码返回“null”。任何帮助使它工作将不胜感激。谢谢!
这是我的代码,无论网格中的“Id & Qualify”字段中显示了多少“是”,它当前都返回 null:
function YesCount(executionContext) {
var formContext = executionContext.getFormContext();
var allRows = null;
var attributeColl = null;
var idqualifyyescount;
var gridContext = formContext.getControl("s_qd");
allRows = gridContext.getGrid().getRows();
allRows.forEach(function (row, rowIndex) {
attributeColl = row.getData().getEntity().attributes;
switch (att.getName()) {
case "new_idqualify":
if (att.getText() = "Yes") {
idqualifyyescount = idqualifyyescount + 1;
}
}
});
if ((idqualifyyescount) > 4) {
Xrm.Page.ui.setFormNotification("WARNING: There are more than 4 Yes's in Sales Quota Distribution grid.", "WARNING");
}
}
解决方案
代替
if (att.getText() = "Yes") {
尝试这个
if (att.getText() == "Yes") {
单等号=
用于分配,而您想要双等号==
用于比较。
推荐阅读
- sql - 不是试图计算课程参与者的 GROUP BY 表达式
- ruby-on-rails - 如何本地化 Rails 活动记录验证中的自定义错误消息?
- reactjs - 看不到通过数据映射的结果
- c++ - 为什么我的静态成员函数会在其他地方抑制文件级静态变量的存在?
- javascript - 如何在 JQuery 显示/隐藏方法中停止重复 div?
- express - ExpressJS - 处理多个页面/分页
- java - 目标运行时 WebSphere Application Server 传统版 V9.0 未定义
- python - 获得最大收益的算法
- filesystems - 在 ubifs 卷上应用增量补丁
- html - 具有三种状态的复选框