Saved searches often require more than simple filters to deliver accurate results. By using AND/OR logic together with parentheses, you can create expressions that define exactly how conditions should be applied. This approach ensures that complex criteria are evaluated in the correct order and that your search results reflect the intended logic.
When parentheses are used, the system processes them from the innermost group outward. For example, in the expression (clauseA AND ((clauseB OR clauseC) AND (clauseD OR clauseE))) OR clauseF, the search engine first evaluates (clauseB OR clauseC) and (clauseD OR clauseE). These results are then combined, followed by clauseA, and finally the outer OR condition with clauseF. This structured evaluation prevents ambiguity and makes your search criteria more reliable.
Consider a practical scenario. Suppose you want to identify transactions that meet certain requirements. You could define criteria such as (Type is 'Invoice' AND (Status is 'Pending Approval' OR Status is 'In Progress')) OR Customer is 'Global Enterprises'. This search will return all invoices that are either pending approval or in progress, as well as any transactions belonging to the customer “Global Enterprises,” regardless of type. By combining conditions in this way, you can capture multiple cases in a single search.
Another example comes from a case where the requirement was to include records if a custom field had no value, but also include records where the field did have a value provided the transaction’s mainline was true. This was implemented using the following expression:
"AND", [[["custbody_jj_so_ref", "is", "@NONE@"]], "OR", [["custbody_jj_so_ref.mainline", "is", "T"]]]
With this setup, the search correctly returns records where the custom field custbody_jj_so_ref is empty, as well as records where the field has a value but the corresponding transaction line is marked as mainline. This kind of expression demonstrates how flexible saved searches can be when handling conditional logic.
To build expressions in a saved search, start by enabling the Use Expressions option on the Criteria subtab. Parentheses can be opened or closed in the Parens column to group conditions. Each filter is defined by selecting a field, setting its criteria, and then choosing whether to connect it with AND or OR. Use AND when records must meet all specified conditions, and OR when records can meet any one of them. If needed, the Not column can be used to exclude records from the results. Once your criteria are complete, add them to the search and either submit it for immediate results or save it for future use.
Expressions provide a straightforward way to manage complex searches. By structuring conditions with logical operators and parentheses, you can create queries that are flexible, accurate, and tailored to your reporting needs.