function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
prakash_sfdcprakash_sfdc 

Rule Engine via Apex (Advanced Filters)

Hi,

I want to create a visualforce page like Advanced filters in List View.

I will give the Rule Criteria like 1 OR (2 AND 3) and Apex should query the object accordingly. I have tried replacing the numbers with field names and generating a dynamic query but it's not helping.

Please help.
ShashForceShashForce
Hi,

If you can post your code snippet and let know where you are stuck, I will be able to have a look and help.

Thanks,
Shashank
prakash_sfdcprakash_sfdc
Assume I need to query the Contacts where Name comes from the filter criteria.

1 OR (2 AND 3)

Hence, query will become

SELECT Id FROM Contact WHERE Name = 'filter1' OR (Name='filter2 AND Name='filter3')

Now Name='filter2 AND Name='filter3' will never give any result. So how do I handle AND condition and the precedence of braces.

I hope it is clear now.
prakash_sfdcprakash_sfdc
It should work like our List view filters...