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 .
  • Eduteam srl Profile Picture
    35 on at
    RE: Javascript addPresearch() not working in version 9.0 plus

    No its the same probelm

  • Suggested answer
    PabloCRP Profile Picture
    1,088 on at
    RE: Javascript addPresearch() not working in version 9.0 plus

    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));
    }

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