Any insight on this. NI'm not used to adding formu...
# suitescript
j
Any insight on this. NI'm not used to adding formula filters to a SS loaded from the UI. Getting this error... "search.createFilter: Missing a required argument: name"... changing formulatext to name does not work.
Copy code
var searchObj = search.load({
    id: 'customsearch_script_inventorybalance',
    type: search.Type.INVENTORY_BALANCE
});
var defaultFilters = searchObj.filters;
var filters = []
if(itemType != '') {
    filters.push(
        {'formulatext':'{item.type}', 'operator':'is', 'values': itemType}
    );
}
if (filters.length > 0) {
    for (var i = 0; i < filters.length; i++) {
        defaultFilters.push(filters[i]);
    }
    searchObj.filters = defaultFilters;
}
a
does the search you're loading already have formula text filters?
I've seen it on columns where they get named with a number at the end so you can reference them. formulatext1 formulatext2 etc... I think? its been a while, not something that comes up that often 😄
b
the objects you push into that filters array must match the parameters to search.createFilter
as noted by the error, the name is required
a
Copy code
filters.push({
    name: 'formulatext'
    operator: 'is'
    values: itemType
    formula: '{item.type}'
});
why do you have to use a formula for item type though? why not just a join to the type field on the item record?
b
that would require the use of the join parameter
a
right...
Copy code
filters.push({
    name: 'type'
    operator: 'is'
    values: itemType
    join: 'item'
});