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 :
Customer experience | Sales, Customer Insights,...
Suggested Answer

Javascript addPresearch() not working in version 9.0 plus

(0) ShareShare
ReportReport
Posted on by 35
var Hospitamanagement=Hospitamanagement || {}
Hospitamanagement.Doctorfilter=function(executionContext)
{
    var formContext = executionContext.getFormContext();
    var department_id=formContext.getAttribute("preetham_departmentid").getValue()[0].id;
    if(department_id!=null)
    {
        var fetchxml="<filter type='and'>"+
        "      <condition attribute='preetham_departmentsid' operator='eq' value='"+department_id+"' />"+
        "    </filter>"
    }
    formContext.getControl("preetham_doctorid").addPreSearch(function(){
        formContext.getControl("preetham_doctorid").addCustomFilter(fetchxml);
    });
}

   
AddPresearch function is not triggering .
I have the same question (0)
  • Suggested answer
    PabloCRP Profile Picture
    1,088 on at

    Hi, you could try removing curly braces to de GUID

    function filterLookup(department_id) {
       var fetchXML = ""  
           ""  
           "";
     
       Xrm.Page.getControl("preetham_doctorid").addCustomFilter(fetchXML);
    }
    var Hospitamanagement=Hospitamanagement || {}
    Hospitamanagement.Doctorfilter=function(executionContext)
    {
        var formContext = executionContext.getFormContext();
        var department =formContext.getAttribute("preetham_departmentid");
        if(department==null)
            return;
        var department_id = department.getValue() != null ?department.getValue()[0].id.replace(/{|}/g,""):"";
          if(department_id=="")
            return;
        Xrm.Page.getControl("preetham_doctorid").addPreSearch(()=>filterLookup(department_id));
    }

  • Eduteam srl Profile Picture
    35 on at

    No its the same probelm

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 > Customer experience | Sales, Customer Insights, CRM

#1
Tom_Gioielli Profile Picture

Tom_Gioielli 74 Super User 2025 Season 2

#2
Daniyal Khaleel Profile Picture

Daniyal Khaleel 32 Most Valuable Professional

#3
Gerardo Rentería García Profile Picture

Gerardo Rentería Ga... 31 Most Valuable Professional

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans