Wednesday 30 January 2013

Count Sub-grid records in entity in CRM 2011 using javascript



function requisitionproducts() {
//Get Current record Id
    var Guid = Xrm.Page.data.entity.getId();
    var fetchXml =
    "<fetch mapping='logical'>" +
       "<entity name='quotedetail'>" + //SubGrid entity name
    //Condition to Check the subGrid record is associated with current record      
          "<filter>" +  
             "<condition attribute='quoteid' operator='eq' value='" + Guid + "' />" +
          "</filter>" +
       "</entity>" +
    "</fetch>";
   
    var fetchedRecord = XrmServiceToolkit.Soap.Fetch(fetchXml)
    if (fetchedRecord.length > 0) {
        return true;
    }
}


After adding this web-resource you need to add the following files to your form page Libraries:

  1. Json
  2. jquery
  3. xrmservicetoolkit


No comments:

Post a Comment