Javascript Error - addPreSearch is not a function - Dynamics CRM

1.3k Views Asked by At

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.

1

There are 1 best solutions below

0
On BEST ANSWER

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

formContext.getControl(arg).addPreSearch(myFunction)

Commnutiy forum for reference