web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

Look Up Record Default Entity Scripts Not Working in CRM 2013

(0) ShareShare
ReportReport
Posted on by

Hello all,

I can't seem to get the scripts in my email activtity form to work in CRM 2013. I have the following functions in my OnLoad event for the email activity form:

function DefaultToLookUp()
{
document.getElementById('to').setAttribute('defaulttype', '2');
Xrm.Page.getControl('to').setDefaultView('A2D479C5-53E3-4C69-ADDD-802327E67A0D');
}

function DefaultRegardingLookUp()
{
document.getElementById('regardingobjectid').setAttribute('defaulttype', '3');
Xrm.Page.getControl('regardingobjectid').setDefaultView('9EB361B4-67AC-4830-8ABF-2D29EFBAEE2C');
}

These used to set the default entity to contact for the "To" field and opportunity for the "Regarding"field in CRM 2011. Your assistance is appreciated!

*This post is locked for comments

I have the same question (0)
  • Vijay Waghmare Profile Picture
    on at

    CRM 2013 introduce new feature to have a runtime filtered view for lookup control – addCustomFilter.

    Please refer below blog for more details

    community.dynamics.com/.../addcustomfilter-method-for-lookup-control-in-crm2013.aspx

    Hope this helps.

    Thanks,

    Vijay

  • Community Member Profile Picture
    on at

    Vijay,

    I'm not sure if I'm being clear enough... My requirement isn't to filter the lookup control. I need to change the default entity from "account" to "contact" in the "to" field's lookup record window in the email activity form. This way, my users don't have to select contact from the drop down menu.

  • tcardenas Profile Picture
    105 on at

    I have the exact same issue :'(

  • abhicrm Profile Picture
    15 on at

    Did anyone get a solution for this, the above script is not working and custom filter does not solve the problem.

    please post the solution, if anyone found it.

    thanks

    Abhi

  • PriscillaT Profile Picture
    515 on at

    Hi,

    Am I correct in assuming that:

    document.getElementById('to').setAttribute('defaulttype', '2');

    no longer works for CRM 2013 is because this is explicit manipulation of the DOM which is unsupported? I have yet to find a way in the new CRM 2013 SDK that would allow me to specify the entityType (e.g. default to say "contact" rather than "account").

    I also tried "addCustomView" by creating a specific view. In this method there is a parameter that allows me to specify the entityType and because I can specify the entityType, it managed to resolve the view GUID and correctly show the specified view in the lookup dialog window.

    Can Microsoft support advise whether an extra parameter for "setDefaultView" might be introduced in the future that allows for specifying the entityType so I won't have to replicate a systemView as a customView in order to use "addCustomView" method in SDK to specify entityType in the lookup dialog?

    Thanks.

  • nitinitin11@hotmail.com Profile Picture
    5 on at

    Hi, Do any one find any solution for this? I tried all possible ways using java-script to set default view on Customer look-up field in Case entity to contact from account but not succeed. If any one came across solution,please revert.

    Thanks in advance.

  • abhicrm Profile Picture
    15 on at

    Hello ,

    This was an identified bug in CRM 2013, microsoft has released rollup 1 , which will resolve the issue with working of custom filter,

    on online , rollup 1 is already published, if yours is onpremise better get rollup 1 and try.

    Regards

    Abhi

  • CCDTrain Profile Picture
    5 on at

    Our environment is currently on rollup 1 and we are experiencing the same issue mentioned above.  Xrm.Page.getControl("").setDefaultView() does not work.

  • Peter Moss Profile Picture
    295 on at

    did anyone find the solution for this? still doesn't work with UR2.

    Thanks

  • tcardenas Profile Picture
    105 on at

    Take a look here,

    dynamicscrmusualsuspect.blogspot.com/.../CRM2013ChangedefaultentityforaLookupfield.html

    I tested this and seems to work; however, I have not tried to make this a permanent solution since it seems very unsafe in terms of maintainability.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

#1
SA-08121319-0 Profile Picture

SA-08121319-0 4

#1
Calum MacFarlane Profile Picture

Calum MacFarlane 4

#3
Alex Fun Wei Jie Profile Picture

Alex Fun Wei Jie 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans