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

倖福魔咒の 提交于 2019-12-01 11:35:15

问题


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.


回答1:


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.



来源:https://stackoverflow.com/questions/29256667/lookup-contacts-instead-of-accounts-on-emails-in-ms-dynamics-crm-2013

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!