首页 > 解决方案 > 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");
    }
}

标签: javascriptdynamics-crm

解决方案


代替

if (att.getText() = "Yes") {  

尝试这个

if (att.getText() == "Yes") {

单等号=用于分配,而您想要双等号==用于比较。


推荐阅读