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:
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:
1 - What happens when you debbug? I see a breakpoint there, does the code hit it?
---> It hits, the debugger.
2 - What is inside "requiredFields" array? My guessing is that it does not enter on that FOR iteration because maybe that split isn't correct.
---> No it is. I have debugged the loop from end to end.
Hi,
1 - What happens when you debbug? I see a breakpoint there, does the code hit it?
2 - What is inside "requiredFields" array? My guessing is that it does not enter on that FOR iteration because maybe that split isn't correct.
Regards,
Joana
In your above code you missed to close the condition tag. This might be the problem
Could you please share debugging screenshot with the value in add watch window here.
The filter query is correct. I have already tested it. No problem with that.
Hi Mohd ,
Use CRMRestBuilder to generate your query , seems the problem is not getting correct value while filtering. You can try to debug and check whether value you are adding in the filter criteria are correct or not.
Try if this works.
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 = 0; i < solutionSettingResults.entities.length; i++) {
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 = 0; j < requiredFields.length; j++) {
if (requiredFields[j] != '') {
filter += "<value>" + requiredFields[j] + "</value>";
}
}
filter += '</condition></filter>';
}
// var formContext = executionContext.getFormContext();
formContext.getControl("tco_primary_tag").addCustomFilter(filter);
}
});
Thanks!
Kirsh
Hi,
I don't find something unusual on your code but this minor change helps
var filter = "<filter type='and'><condition attribute='tco_category' operator='in'>"
for (var j = 0; j < requiredFields.length; j++) {
if (requiredFields[j] != '') {
debugger;
filter += "<value>" + requiredFields[j] + "</value>";
}
}
filter += '</condition></filter>';
Hope it helps
Stay up to date on forum activity by subscribing. You can also customize your in-app and email Notification settings across all subscriptions.
André Arnaud de Cal... 291,280 Super User 2024 Season 2
Martin Dráb 230,235 Most Valuable Professional
nmaenpaa 101,156