Recently we got a requirement to set default view for marketing list inline lookup view on Contact Form. As we can’t customize the inline lookup view directly on Form editor, we need to write a piece of JS code to achieve this. The tricky part is to get the control name of the inline lookup. You can access the control like “lookup_subgridname” (case sensitive), for ex, in my case: “lookup_Marketinglisten”. We need to use “setTimeout” as the control will take some time to load on the Form.
JS Code (Form OnLoad event)
function filterMarketingListInlineLookupView() {
var marketingListInlineLookup = Xrm.Page.getControl(“lookup_Marketinglisten“);
if (marketingListInlineLookup) {
var activeMarketingListViewId = “{4bee031e-04d6-e811-8160-5065f38a4a31}”;
var defaultView = marketingListInlineLookup.getDefaultView();
if (defaultView != activeMarketingListViewId) {
marketingListInlineLookup.setDefaultView(activeMarketingListViewId);
}
}
setTimeout(function () { filterMarketingListInlineLookupView(); }, 500);
}
Hope it helps.