Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Customer experience | Sales, Customer Insights,...
Suggested answer

Javascript Error - addPreSearch is not a function - Dynamics CRM

(0) ShareShare
ReportReport
Posted on by 295

I am trying to filter the lookup based on some conditions and hence using addPreSearch. I am using the following code,

function filterLookup() {
    debugger;
  try {

    var conditionalattribute= Xrm.Page.getAttribute("vrp_conditionalattribute").getValue();

    if (conditionalattribute!= null && conditionalattribute!= undefined)
    {
        Xrm.Page.getAttribute("filteredattribute").addPreSearch(function () {
            addLookupFiler();
        });
    }
}
catch (e) {
    console.log(e.Message);
}

}

But I am getting below error on addPreSearch line

pastedimage1601396259864v1.jpeg

Please note that I am using CRM v8.2.

  • Suggested answer
    LeoAlt Profile Picture
    16,331 Moderator on at
    RE: Javascript Error - addPreSearch is not a function - Dynamics CRM

    Hi Partner,

    Now the "addPreSearch" has been moved to formContext.getControl();

    pastedimage1601447420382v1.png

    https://docs.microsoft.com/en-us/powerapps/developer/model-driven-apps/clientapi/reference/controls/addpresearch

    Please try "formContext.getControl(arg).addPreSearch(myFunction)".

    Regards,

    Leo

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

🌸 Community Spring Festival 2025 Challenge Winners! 🌸

Congratulations to all our community participants!

Adis Hodzic – Community Spotlight

We are honored to recognize Adis Hodzic as our May 2025 Community…

Kudos to the April Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard > Customer experience | Sales, Customer Insights, CRM

#1
Daivat Vartak (v-9davar) Profile Picture

Daivat Vartak (v-9d... 225 Super User 2025 Season 1

#2
Muhammad Shahzad Shafique Profile Picture

Muhammad Shahzad Sh... 97

#3
Vahid Ghafarpour Profile Picture

Vahid Ghafarpour 82 Super User 2025 Season 1

Overall leaderboard

Product updates

Dynamics 365 release plans