Maximum record limit is exceeded reduce the number of records

Normally when we navigating from one view to another view in CRM , CRM will actually showing the results based on the criteria configured in the view. If the result of the queried view is exceeds the default AggregateQueryRecordLimit in CRM then CRM will show the error message like “Maximum record limit is exceeded reduce the number of records”

In order to overcome this we need to update the limit value in MSCRM_Config db.

select ColumnName,IntColumn from DeploymentProperties where ColumnName=’AggregateQueryRecordLimit’

By default IntColumn value is 50000.

To update it we can specify our desired limit like below.

Update DeploymentProperties
Set IntColumn=99999
Where ColumnName=’AggregateQueryRecordLimit’

Note: If we increase the limit there may be a performance degradation happen. Because this limit is applicable across the CRM platform.


Accessing the names of the attributes or controls Xrm.Page object model

1.Access a specific subgrid control by name.

Below function will be written The names of all the subgrid controls
 if(ctrl.getControlType() == "subgrid")

2. Show the names of all attributes in a form with their type

function (att, i) {
 console.log(att.getName() + " : " + att.getAttributeType())

3. Show the valid option values for optionset attributes

function (att, i) {
 if (att.getAttributeType() == "optionset") {
  var options = att.getOptions();
  var optionsLength = options.length;
  for (var i = 0; i < optionsLength; i++) {
   var option = options[i];
   console.log("   value: " + option.value + " Label: " + option.text)



Form programming methods

The following table lists the form programming methods available for updated entities only.

Method Description
Xrm.Page.context.client.getClient Returns a value to indicate which client the script is executing in.
Xrm.Page.context.client.getClientState Returns a value to indicate the state of the client.
Xrm.Page.context.getUserName Returns the name of the current user. Gets a string for the value of the primary attribute of the entity. Asynchronously refreshes the data of the form without reloading the page. Saves the record asynchronously with the option to set callback functions to be executed after the save operation is completed. attribute.getIsPartyList Determines whether a lookup attribute represents a partylist lookup.
Xrm.Page.ui control.clearNotification Removes a message already displayed for a control.
Xrm.Page.ui control.setNotification Displays a message near the control to indicate that data is not valid.
Xrm.Page.ui.clearFormNotification Use this method to remove form level notifications.
Xrm.Page.ui.setFormNotification Use this method to display form level notifications.
Xrm.Page.ui control.addCustomFilter Use fetchXml to add additional filters to the results displayed in the lookup. Each filter will be combined with any previously added filters as an ‘AND’ condition.
Xrm.Page.ui control.setShowTime Specifies whether a date control should show the time portion of the date.
Xrm.Utility.alertDialog Displays a non-blocking alert dialog with a callback function.
Xrm.Utility.confirmDialog Displays a non-blocking confirm dialog with different callbacks depending on the button clicked by the user.

PreSearch Event in Microsoft Dynamics 365

PreSearch event for updated entities

The new PreSearch event occurs just before the search dialog box opens when you set a lookup value. This event does not have user interface to set an event handler in the application; it can only be set using the Xrm.Page.ui control.addPreSearch method. Use this event with the addCustomFilter, addCustomView and setDefaultView methods to control the views opened when people search for a record to set as the value of a lookup field.

Use this method to apply changes to lookups based on values current just as the user is about to view results for the lookup.

Type: Function to add.

This method is only available for Updated entities.

The argument is a function that will be run just before the search to provide results for a lookup occurs. You can use this handler to call one of the other lookup control functions and improve the results to be displayed in the lookup.


Use this method to remove event handler functions that have previously been set for the PreSearch event.

Type: Function to remove.

This method is only available for Updated entities.

Using below function we can Set Current System Time only to Date Field

function SetCurrentTimeOnly(fieldname) {

var d = Xrm.Page.getAttribute(fieldname).getValue();
var mydate = new Date();
var s = mydate.getSeconds();
var m = mydate.getMinutes();
var h = mydate.getHours();

if (d != null) {
if (d.getHours() == 0) {



Validate Phone Number Field in MS CRM

*******************************Validate Phone Number Field**************************************
function ValidatePhoneNumber() {
// Binding the events to crm field, which needs to be validated
crmForm.all.<FieldName>.onkeypress = isvalidPhone;

// Allows to enter only Numbers & upto 10 char’s
function isvalidPhone() {

var charCode = event.keyCode;
if (charCode > 31 && (charCode < 48 || charCode > 57))
return false;

var phnum = event.srcElement.value.replace(/[^0-9]/g, “”);

if (phnum.length >= 10)
return false;
return true;