We are working on a requirement where User is presented with a form(which is a Vf page)as below. enter image description here

When any of the fields is entered(say Email) and submitted, it needs to be navigated to a report which displays the resultant data. I came to know that we can use dynamic parameter passing to report from Visualforce for this scenario. We have created Report for the same with 3 filter fields called Email, Name and Type. But facing some issue on how to frame the filter criteria in the report. In Controller we wrote something like this to fetch the data based on the fields entered by the user:

String query ='Select Id, Emp_Name__c, Emp_Email__c,Type__c from Employee__c where Status__c!=null ';
if(enteredEmail!='' && enteredEmail!=null)
    query+= ' and Emp_Email__c=:enteredEmail ';
if(enteredName!='' && enteredName!=null)
    query+= ' and Emp_Name__c=:enteredName';
if(selectedType!='' && selectedType!=null)
    query+= ' and Type__c=:selectedType';
List<Employee__c> result = Database.query(query);

To mimic the above conditions in the report, we gave filter criteria as below which is not working:

  1. Status not equal to ""

  2. Email not equal to ""

  3. Email equals ""

  4. Name not equal to ""

  5. Name equals ""

  6. Type not equal to ""

  7. Type equals ""

Filter Logic : ( 1 AND (2 AND 3) AND (4 AND 5) AND (6 AND 7) )

For 3, 5 and 7 above, parameters(pv2, pv4 and pv6) will be passed dynamically from Vf to the report in the URL.

Please let me know if the above filter logic is correct or need any modifications. Thanks.

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Browse other questions tagged or ask your own question.