In my Opportunity form, I've added a "Sales Quota Distribution" entity editable grid. One Opportunity can have many Sales Quota Distribution records. I am working on a JavaScript event that counts how many records = "Yes" in the "ID & Qualify" field for records shown in the Sales Quota Distrubution grid. "ID & Qualify" is a dropdown field, and the two options it contains are Yes and No. I believe I am close to being done, but the code is returning "null" for some reason. Any help getting this to work would be greatly appreciated. Thank you!
Here is my code, which is currently returning null regardless of how many "Yes"'s are shown in the "Id & Qualify" field in the grid:
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");
}
}