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

Lookup filtering not working for dynamically created fetch xml for addfilter function

$
0
0

Hi guys,

I am using the presearch and addfilter function in a combination. Everything seems to work fine when I use a hardcoded filter like below:

function addPrimaryTagLookupFilter(executionContext) {

    var filter =        "<filter type='and'>" +
    "<condition attribute='tco_category' operator='in'>" +
    "<value>EADD077E-B0DA-E911-A982-000D3ABA0C96</value>" +
    "<value>ECDD077E-B0DA-E911-A982-000D3ABA0C96</value>" +
    "<value>E6DD077E-B0DA-E911-A982-000D3ABA0C96</value>" +
    "</condition>" +
    "</filter>"
    
    var formContext = executionContext.getFormContext();
    formContext.getControl("tco_primary_tag").addCustomFilter(filter);        

}
But when I try creating the same filter dynamically, it doesn't seems to work. 
                Xrm.WebApi.online.retrieveMultipleRecords("tco_solution_setting""?$select=tco_value&$filter=tco_name eq '" + solutionSettingKey + "'").then(
                    function success(solutionSettingResults) {
                        if (solutionSettingResults.entities.length > 0) {
                            for (var i = 0i < solutionSettingResults.entities.lengthi++) {
                                var tco_value = solutionSettingResults.entities[i]["tco_value"];
                                var requiredFields = tco_value.split(';');
                                // var filter = "<filter type='and'>" + "<condition attribute='tco_category' operator='in'>"
                                for (var j = 0j < requiredFields.lengthj++) { 
                                    if (requiredFields[j!= '') {                                                                            
                                            debugger;
                            filter += "<condition attribute='tco_category' operator='eq' value='" + '{' + requiredFields[j+ '}' + "'/>";

                            //  filter += "<value>" + requiredFields[j]  + "</value>";
                                        }
                                }
                                filter += '</filter></filter>';
                            }
                            // var formContext = executionContext.getFormContext();
                        
                            formContext.getControl("tco_primary_tag").addCustomFilter(filter);    
                        }
                    },
There is no error in the console. But the lookup doesn't gets filtered. Any suggestions guy why this couldn't be working? It's urgent actually. I am working on UCI.

Viewing all articles
Browse latest Browse all 82002

Latest Images

Trending Articles



Latest Images