Michael Philip's Blog

Writing about MS Tech with strong focus on Azure & CRM

Dynamcis 365 – Override Lookup view using Java script

Leave a comment

Hi,

I have encountered some scenarios  in which I needed to override lookup view columns or apply some filters on the results depending on dynamics conditions at run time on CRM form.

In order to do that , add the following piece of code in the on load event

The following example filters results set no a specific case type

 

var viewId = “{00000000-0000-0000-0000-000000000001}”;

//add the entity name
var entityName = “incident”;

// add the view display name
var viewDisplayName = “Problem Cases”;

var fetchXml = “<fetch version=’1.0′ output-format=’xml-platform’ mapping=’logical’ distinct=’false’>” +
“<entity name=’incident’>” +
” <attribute name=’title’ />” +
“<attribute name=’customerid’ />” +
“<attribute name=’incidentid’ />” +
“<order attribute=’title’ descending=’false’ />” +
“<filter type=’and’>” +
“<condition attribute=’bps_type’ operator=’eq’ value=’200000005′ />” +
” </filter>” +
” </entity>” +
“</fetch>”;

var layoutXml = “<grid name=’resultset’ object=’1′ jump=’productid’ select=’1′ icon=’1′ preview=’1′>” +
“<row name=’result’ id=’incidentid’>” +
“<cell name=’title’ width=’150′ />” +
“<cell name=’customerid’ width=’150′ />” +
“</row>” +
“</grid>”;

Xrm.Page.getControl(“parentcaseid”).addCustomView(viewId, entityName, viewDisplayName, fetchXml, layoutXml, true);

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s