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)

Filterd LookUp using Javascript

(0) ShareShare
ReportReport
Posted on by

HI,

I have one Email field and contact lookup in concern form. i need to filter the lookup based on the email.i am using below code. but the values are not coming in the lookup and if we click on the lookup it is giving error saying that contact system admin. on change of email i am refreshing the form and i am calling this function in onLoad. can any one please help on this.

function onLoad() {

Xrm.Page.getControl("sandeep_customername").addPreSearch(function () {
addLookupFilter();
});
}

function addLookupFilter() {
try {
var email = Xrm.Page.getAttribute("sandeep_emailid").getValue();
if (email != null) {
var filter = "<fetch version='1.0' output-format='xml-platform' mapping='logical' distinct='false'>"
+ "<entity name='account'>"
+ "<attribute name='name'/>"
+ "<attribute name='telephone1'/>"
+ "<attribute name='contactid'/>"
+ "<attribute name='emailaddress1'/>"
+ "<order descending='false' attribute='name'/>"
+ "<filter type='and'>"
+ "<condition attribute='sandeep_emailid' operator='like' value='" + email + "'/>"
+ "</filter></entity></fetch>";
Xrm.Page.getControl("sandeep_customername").addCustomFilter(filter);

}
}
catch (ex) {
throw ex
}

}

Thanks.

*This post is locked for comments

I have the same question (0)
  • Verified answer
    Rajkumar Rajaraman Profile Picture
    on at

    Vasanth,

    Refer the following blog:

    www.magnetismsolutions.com/.../crm-2013-javascript-lookup-filtering-using-addcustomfilter

    missdynamicscrm.blogspot.in/.../filter-lookup-field-by-related-subgrid-crm-2011-2013.html

    Hope this helps.

    Regards,

    R.Rajkumar

    "Please mark my answer as verified if you found it helpful"

  • Verified answer
    Mehdi Chemseddine Profile Picture
    110 on at

    Hi,

    Try this by adding '%' in the condition value :

    "<condition attribute='sandeep_emailid' operator='like' value='" + email + "%'/>"

    And check the links provided by Raj.

    BR

  • Verified answer
    Mahendar Pal Profile Picture
    45,095 on at

    Hello,

    You don't need to specify all the fetch you can just use the filter and filter the lookup. Also apart from that, do you think there will be multiple accounts with the same email address, because this not a normal business scenario only one account will have this email, so instead of filtering lookup you can write java script to pre populate the account lookup by writing OData call, just an idea :)

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