How can I simplify the salesforce filter logic?

288    Asked by DavidEDWARDS in Salesforce , Asked on May 15, 2023

 Is there a way to simplify the below filter logic as it exceeds what is allowed character wise in SalesForce? I tried (1 AND 2 AND 6 AND 7 AND (5 AND 9 AND 3 OR 4)) OR (1 AND 2 AND 3 AND 8 AND 10) but got the following error: "Your filter is missing the right operand to AND or OR".

What I'm trying to simplify:

(1 AND 2 AND 5 AND 6 AND 7 AND 9 AND 3) OR (1 AND 2 AND 4 AND 6 AND 7) OR (1 AND 2 AND 3 AND 8 AND 10)
Answered by Diya tomar

To simplify the salesforce filter logic -

The rule for parentheses is that every operator within a group must be AND or OR. (5 AND 9 AND 3 OR 4) violates this rule. I ended up reordering the original filter and spaced out the values to come up with:

(1 AND 2 AND 3 AND 5 AND 6 AND 7 AND 9 ) OR (1 AND 2 AND 4 AND 6 AND 7 ) OR (1 AND 2 AND 3 AND 8 AND 10)
From there, I could see the common groups [1, 2], [3, 5, 9], [3, 8, 10], [4], and [6, 7].
After some more reordering, I ended up with the following:
1 AND 2 AND ((3 AND 8 AND 10) OR (((3 AND 5 AND 9) OR 4) AND 6 AND 7))
I'm pretty sure this is correct, but you'll want to verify this for yourself on paper.

Your Answer

Interviews

Parent Categories