Quantcast
Channel: Microsoft Dynamics CRM Forum - Recent Threads
Viewing all articles
Browse latest Browse all 79901

Need help finishing JavaScript event that counts the total "Yes"s in a grid and gives a warning message if the "Yes" count >4

$
0
0

In my Opportunity form, I've added a Sales Quota Distribution Grid (See screenshot below).  If more than four Yes's have been entered in the entire grid, I want a warning message (or something similar) to be shown.  For example, in the screenshot below, the "svc, Azure" account has 4 fields marked "Yes".  The "XXXX, XXXX" account has zero.  If I change one the distributions next to "XXXX, XXXX", I want the warning message to appear.

I'm trying to create a JavaScript event to get this functionality to work.  However, I don't have much JavaScript experience and could use some help getting this to work.  Here is what I have so far:

function GetTotalYesCount() {
    var selectedRow = null;
    var attributeColl = null;
    var idqualifyyescount;
    var sowbomyescount;
    var scopeyescount;
    var closeyescount;
    try {
        //get the selected rows - use the getControl method and pass the grid name.
        selectedRow = Xrm.Page.getControl("s_qd").getGrid().getSelectedRows();
        //loop through rows and get the attribute collection
        selectedRow.forEach(function (row, rowIndex) {
            //get the attribute Collection
            attributeColl = row.getData().getEntity().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.");
                        }                      
}
}
}
}
Am I on the right track?  Any help getting this to work would be greatly appreciated.  Thanks in advance!!


Viewing all articles
Browse latest Browse all 79901

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>