Faran Saleem
Faran Saleem

Reputation: 414

Javascript Error - addPreSearch is not a function - Dynamics CRM

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

enter image description here

Please note that I am using CRM v8.2.

Upvotes: 0

Views: 1562

Answers (1)

AnkUser
AnkUser

Reputation: 5531

you do not get presearch on attribute but rather it's control

formContext.getControl(arg).addPreSearch(myFunction)

Commnutiy forum for reference

Upvotes: 1

Related Questions