Nick
02/16/2021, 4:15 PMvar childCustomerSearch = search.load({
id: 'customsearch_kescp_so_child_customer_sea'
});
if (childCustomerSearch.filters.length > 0) {
childCustomerSearch.filters.push('AND');
childCustomerSearch.filters.push([["internalid","anyof","578029"],"OR",["parentcustomer.internalid","anyof","578029"]]);
} else {
childCustomerSearch.filters.push([["internalid","anyof","578029"],"OR",["parentcustomer.internalid","anyof","578029"]]);
}
Sandii
02/16/2021, 4:27 PMbattk
02/16/2021, 4:28 PMNick
02/16/2021, 4:29 PMbattk
02/16/2021, 4:33 PMSandii
02/16/2021, 4:34 PMsearch.filterExpression
property, there is no such thing as search.createFilterExpression. I did not not fully read what you were doing, you can ignore my original comment unless building simple filters that are all AND
battk
02/16/2021, 4:34 PMNick
02/16/2021, 4:36 PMSandii
02/16/2021, 4:37 PMNick
02/16/2021, 6:22 PMfor (var i = 0; i < customSearchFilters.length; i++) {
newFilters.push([customSearchFilters[i].name, customSearchFilters[i].operator, customSearchFilters[i].values])
}
Nick
02/16/2021, 6:22 PMSandii
02/16/2021, 6:26 PMNick
02/16/2021, 6:27 PMvar childCustomerSearch = search.load({
id: 'customsearch_kescp_so_child_customer_sea'
});
var customSearchFilters = childCustomerSearch.filters;
var newFilters = [];
log.debug({'title':'customSearchFilters', 'details': customSearchFilters});
for (var i = 0; i < customSearchFilters.length; i++) {
newFilters.push([customSearchFilters[i].name, customSearchFilters[i].operator, customSearchFilters[i].values])
}
if (newFilters.length > 0) {
newFilters.push('AND');
newFilters.push([["internalid","anyof", cacheObj.companyid],"OR",["parentcustomer.internalid","anyof", cacheObj.companyid]]);
} else {
newFilters.push([["internalid","anyof", cacheObj.companyid],"OR",["parentcustomer.internalid","anyof", cacheObj.companyid]]);
}
childCustomerSearch.filterExpression = newFilters;
Sandii
02/16/2021, 6:27 PMNick
02/16/2021, 6:29 PMvar childCustomerSearch = search.load({
id: 'customsearch_kescp_so_child_customer_sea'
});
var customSearchFilters = childCustomerSearch.filters;
var newFilters = [];
log.debug({'title':'customSearchFilters', 'details': customSearchFilters});
for (var i = 0; i < customSearchFilters.length; i++) {
newFilters.push([customSearchFilters[i].name, customSearchFilters[i].operator, customSearchFilters[i].values])
}
if (newFilters.length > 0) {
newFilters.push('AND');
newFilters.push([["internalid","anyof", cacheObj.companyid],"OR",["parentcustomer.internalid","anyof", cacheObj.companyid]]);
} else {
newFilters.push([["internalid","anyof", cacheObj.companyid],"OR",["parentcustomer.internalid","anyof", cacheObj.companyid]]);
}
childCustomerSearch.filterExpression = newFilters;
Sandii
02/16/2021, 6:30 PMAND
in between each of them if there are more than oneNick
02/16/2021, 6:31 PMSandii
02/16/2021, 6:33 PMnewFilters
before you set it as the filterExpression and make sure the array makes sense would be where I would start.Nick
02/16/2021, 6:33 PM[["custentity_customer_ship_to","anyof",null],"AND",[["internalid","anyof","578029"],"OR",["parentcustomer.internalid","anyof","578029"]]]
Sandii
02/16/2021, 6:35 PMNick
02/16/2021, 6:35 PMSandii
02/16/2021, 6:38 PM_rawFilters
instead of filters
Sandii
02/16/2021, 6:38 PMvalues
property associated with .filters
when I am loading a search in the consoleNick
02/16/2021, 6:39 PMSandii
02/16/2021, 6:40 PMvar customSearchFilters = childCustomerSearch.filters;
to ._rawFilters
, or just read directly from the original .filterExpression
and modify that.Sandii
02/16/2021, 6:46 PMvar searchObj = search.load(); //load search
var newFilters = searchObj.filterExpression; //comes back as array
newFilters.push(
'AND',
[[], 'OR', []]//your new stuff here
)
searchObj.filterExpression = newFilters;
something like this should workNick
02/16/2021, 7:17 PMRoc127
05/21/2021, 9:11 AM