web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

No record found.

News and Announcements icon
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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Stars!

Meet the Microsoft Dynamics 365 Contact Center Champions

We are thrilled to have these Champions in our Community!

Congratulations to the April Top 10 Community Leaders

These are the community rock stars!

Leaderboard > Customer experience | Sales, Customer Insights, CRM

#1
ManoVerse Profile Picture

ManoVerse 128 Super User 2026 Season 1

#2
11manish Profile Picture

11manish 95

#3
Muhammad Shahzad Shafique Profile Picture

Muhammad Shahzad Sh... 69 Most Valuable Professional

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans