Hello Sir,
I have a product subgrid on lead form and I have written a javascript code to count number of products present in subgrid .
My code :
function SelectProductFamily_OnLoad(executionContext) {
// debugger;
var formContext = executionContext.getFormContext();
var formType = formContext.ui.getFormType();
setTimeout(function () {
debugger;
if (formContext.getControl("productsubgrid") != undefined && formContext.getControl("productsubgrid") != "") {
var leadCount = formContext.getControl("productsubgrid").getGrid().getTotalRecordCount();
// alert(leadCount);
var x = parseInt(leadCount);
if (formType == 2 && x == 0) {
formContext.ui.setFormNotification("Please Add Product Family.", "ERROR", "1");
}
else {
formContext.ui.clearFormNotification("1");
}
};
}, 2000);
}
it works but when after save and agin load the lead it shows message : "Please Add Product Family."