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

    No its the same probelm

  • Suggested answer
    PabloCRP Profile Picture
    PabloCRP 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

Announcing Our 2025 Season 1 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Vahid Ghafarpour – Community Spotlight

We are excited to recognize Vahid Ghafarpour as our February 2025 Community…

Tip: Become a User Group leader!

Join the ranks of valued community UG leaders

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 292,494 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 231,309 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans