简体   繁体   中英

Lookup contacts instead of accounts on emails in MS Dynamics CRM 2013

I planning change default view for to attribute on email entity, so instead of account entity it will suggest user to choose recipients among contacts .

However this functionality in MS Dynamics CRM seems to be broken. Or I missing something?

Here is the code:

(function () {
    var ctrl = Xrm.Page.getControl("to");

    if (ctrl) {
        ctrl.setDefaultView('{13C1A58B-9AEF-4164-80E5-1D946D5BC8B3}');
        console.log("Default view is set!");
    }
}())

Guid points to valid view on contact entity. The code is executed, console has debug message Default view is set! , and on using to lookup system still uses account by default.

Did somebody found workaround for this issue? In supported way, of course.

I was lucky to find supported, but still a bit tricky way how to achieve needed result without hacking CRM core.

The basic idea is to add any custom view to selected control, and than setDefaultView to any needed view that valid for the entity.

So code in the question could be rewritten as:

(function () {
    var ctrl = Xrm.Page.getControl("to");

    if (ctrl) {
        // Add custom view based 
        ctrl.addCustomView('{71C254C1-1F55-43B7-94DE-C461DB617A77}', 'contact', 'View Name', '<xml> valid FetchXML statement </xml>', '<xml> valid LayoutXML statement </xml>', true);
        ctrl.setDefaultView('{13C1A58B-9AEF-4164-80E5-1D946D5BC8B3}');
        console.log("Default view is set!");
    }
}())

Actually after new custom view is set, any valid view could be set as default. This could be either custom or system view.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM