Quantcast
Channel: Microsoft Dynamics CRM Forum - Recent Threads
Viewing all articles
Browse latest Browse all 79901

Xrm.Page.getControl addPreSearch is there a bug with CRM 2016

$
0
0

Hi,

Is there a bug with using addPreSearch with 2016.   I have seen many examples can't seem to get my code to work.

I am triggering my code at Form (OnLoad).

The function is not being called.  When debugging the code is being skipped an not throwing an error message.

Xrm.Page.getControl("new_casemodelid").addPreSearch(addLookupFilter);

function filterLookup() {
    try{
        // validate Case Model field data
        if (Xrm.Page.getControl("new_caseid") != null && Xrm.Page.getControl("new_caseid") != undefined) {
            //call filter method on pre search of lookup field

//Below code is being skip
Xrm.Page.getControl("new_casemodelid").addPreSearch(addLookupFilter); } } catch (e) { //throw error throw new Error(e.message); } } function addLookupFilter() { try { var caseLookup = Xrm.Page.getAttribute("new_caseid").getValue(); //Validate Case Id if (caseLookup != null && caseLookup != undefined) { var caseId = caseLookup[0].id.replace(/{/g, '').replace(/}/g, ''); //Prepare Condition for the filter fetchXml = "<filter type='and'><condition attribute='new_caseid' operator = 'eq' value '" + caseId + "' /></filter>"; //Apply Filter to the lookup field Xrm.Page.getControl("new_casemodelid").addCustomFilter(fetchXml); } } catch (e) { //throw error throw new Error(e.message); } }



Viewing all articles
Browse latest Browse all 79901

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>