function addcustomview() {
//Step 1 -> Declare variables
var viewId = "{1a318cee-edf7-4685-a3ad-5926cad689a1}"; //Generate new guid
var entityName = "sama_baragetype"; // Entity to be filtered
var viewDisplayName = "Custom view "; // Custom name for the lookup window.
var fetchXml =
"<fetch version='1.0' output-format='xml-platform' mapping='logical' distinct='false'>" +
"<entity name='an_chargetype' >" +
"<attribute name='sama_baragetypeid'/>" +
"<attribute name='sama_baragecode/>" +
"<attribute name='createdon' />" +
"<order attribute='an_baragecode' descending='false' />" +
"<filter type='and'>" +
"<condition attribute='an_requesttype' operator='eq' value='875950000' />" +
"</filter>" +
"</entity>" +
"</fetch>";
// Step 2 --> Build Grid Layout for the field to populate the lookup
var layoutXml = "<grid name='resultset' " +
"object='1' " +
"jump='sama_baragecode' " +
"select='1' " +
"icon='1' " +
"preview='1'>" +
"<row name='result' " +
"id='sama_baragetypeid'>" + // Id attribute of the entity to be filtered
"<cell name='sama_baragecode' " +
"width='300' />" +
"<cell name='createdon' " + //Column1 - Salutation
"width='300' />" +
"</row>" +
"</grid>";
//Step 3 Adding the custom view to the lookup
Xrm.Page.getControl("<logical name of field to populate>").addCustomView(viewId, entityName, viewDisplayName, fetchXml, layoutXml, true);
}
Add jquery , json library files to make it work of crm form.
//Step 1 -> Declare variables
var viewId = "{1a318cee-edf7-4685-a3ad-5926cad689a1}"; //Generate new guid
var entityName = "sama_baragetype"; // Entity to be filtered
var viewDisplayName = "Custom view "; // Custom name for the lookup window.
var fetchXml =
"<fetch version='1.0' output-format='xml-platform' mapping='logical' distinct='false'>" +
"<entity name='an_chargetype' >" +
"<attribute name='sama_baragetypeid'/>" +
"<attribute name='sama_baragecode/>" +
"<attribute name='createdon' />" +
"<order attribute='an_baragecode' descending='false' />" +
"<filter type='and'>" +
"<condition attribute='an_requesttype' operator='eq' value='875950000' />" +
"</filter>" +
"</entity>" +
"</fetch>";
// Step 2 --> Build Grid Layout for the field to populate the lookup
var layoutXml = "<grid name='resultset' " +
"object='1' " +
"jump='sama_baragecode' " +
"select='1' " +
"icon='1' " +
"preview='1'>" +
"<row name='result' " +
"id='sama_baragetypeid'>" + // Id attribute of the entity to be filtered
"<cell name='sama_baragecode' " +
"width='300' />" +
"<cell name='createdon' " + //Column1 - Salutation
"width='300' />" +
"</row>" +
"</grid>";
//Step 3 Adding the custom view to the lookup
Xrm.Page.getControl("<logical name of field to populate>").addCustomView(viewId, entityName, viewDisplayName, fetchXml, layoutXml, true);
}
Add jquery , json library files to make it work of crm form.