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
Andrea SloanAndrea Sloan 

Passing a VisualForce Filter from a Form to a Report

I am trying to develop a form whereby users can select values for the following filters inside a Visualforce form and then have their entry passed onto my report filter fields in their correct locations. I absolutely need this exercise to be done on the backend through a form as for security reasons, I otherwise have the front end filters of my reports locked up to users.
1. Trave Date From   (designed as a calendar picker or date entry field)
2. Travel Date: To
(designed as a calendar picker or date entry field)
3. Confirm Date (designed to be entered as an option text value such as "This month" or like the other two fileds - calendar picker or date entry)

You will see in my attached form a table with six cells. Let's just focus on the first one labeled "New Confirmed/Travels (This Month) and once it works I'll need the other ones to work as well.

My form data input all works great. There are no issues in inputting the values in the form as desired. The form value entries also pass onto the correct filter value of my report as long as I've entered the date values as dates and not the text value option in the Confirm Date part of the form. If I enter the Confirmed date, the value passes onto PV2 filter in my report which is what I want. If I however enter "Last month", "This Year" etc., although it passes on this word to the report, it doesn't pass it onto the PVS report filter location as it should. Travel Date From is PV0, Travel Date To is PV1 and Confirm Date is PV2. Why does it not pass on my text entry of confirm date correctly inside my report? Can you help me with the coding part which may be incorrect?
I am pasting my code as well as a screenshot of my form and the New Confirmed/Travels (This Month) report which goes with the first cell of the form.

<apex:Page >
    <head>
        <link rel="stylesheet" href="//code.jquery.com/ui/1.11.4/themes/smoothness/jquery-ui.css"/>
        <script src="//code.jquery.com/jquery-1.10.2.js"></script>
        <script src="//code.jquery.com/ui/1.11.4/jquery-ui.js"></script>
        <link rel="stylesheet" href="/resources/demos/style.css"/>
        <script>
            $(function() {
                $("#pv2").datepicker({changeMonth: true, changeYear: true});
                 $("#pv12").datepicker({changeMonth: true, changeYear: true});         
                $(".datepick").datepicker({changeMonth: true, changeYear: true, constrainInput: false});     
              });            
        </script>      
       <script>
           function getComboA(sel,inputId) {
                document.getElementById(inputId).value = sel.value;
            }
       </script> 
    </head>
    Hello  {! $User.FirstName}
    <br/>
    <B>Use the date fields below to view Travel Dates for a specific time period</B>
    <TABLE Border= "3" CELLSPACING="1" CELLPADDING="1" columnClasses="red,green,blue">
        <br/>
        <CAPTION><B> Salesforce Reports </B></CAPTION>
        <br/>
        <TR>
            <TD ALIGN = "Center">
                <B>Opportunity Reports</B>
            </TD>
            <TD ALIGN = "Center">
                <B> Visit Summary Reports</B>
            </TD>
        </TR>
        <TR>
            <TD>
                <form method="get" action="/00OE0000002ujMC" >          
                <B>New Confirmed/Travels (This Month)</B>
                <BR/>
                <b>Date Ranges:</b>
               <br/>
               Travel Date From (MM/DD/YYYY):
                <input type="text" name="pv0" id="pv0" class="datepick" /> <br/>
                Travel Date To (MM/DD/YYYY):
                <input type="text" name="pv1" id="pv1" class="datepick" />
                <br />
                Confirm Date (MM/DD/YYYY):
                <input type="text" name="pv2" id="pv2" style="width: 90px;" onchange="getComboA(pv2,'pv3')"/>
                <select name ="pv2" id="pv2" onchange="getComboA(pv2,'pv1')">
                    <option value="This Month">This Month</option>
                    <option value="Last Month">Last Month</option>
                    <option value="This Year">This Year</option>
                    <option value="Last Year">Last Year</option>
                    <option value="Today">Today</option>
                    <option value="Yesterday">Yesterday</option>
                    <option value="This Quarter">This Quarter</option>
                    <option value="Last Quarter">Last Quarter</option>
                     <option value="   ">Blank </option>
                </select><br/>
                <input type="submit" value="My Confirmed Travels" class="submit" />
                </form>
            </TD>
            <TD>
                 <form method="get" action="/00OE0000002us1h" >
                    <B>C- New Visits</B>
                    <br/>
                    <B>Date Ranges:</B>
                    <br/>
                    Travel Date From (MM/DD/YYYY):
                    <input type="text" name="pv0" id="pv4" class="datepick" /><br />
                    Travel Date To (MM/DD/YYYY):
                    <input type="text" name="pv1" id="pv5" class="datepick" />
                    <br />
                    <input type="submit" value="My Visits" class="submit" />
                </form>
            </TD>
        </TR>
        <TR>
            <TD>
                <form method="get" action="/00OE0000002uD4A" >          
                <B>A- Account Yearly Revenue (by Bus Unit)</B>
                <BR/>
                <b>Date Ranges:</b>
                <br/>
                Travel Date From (MM/DD/YYYY):
                <input type="text" name="pv0" id="pv6" class="datepick" /> <br/>
                Travel Date To (MM/DD/YYYY):
                <input type="text" name="pv1" id="pv7" class="datepick" />
                <br />
                <input type="submit" value="Account Yearly Revenue" class="submit" />
                </form>
            </TD>
            <TD>
                <form method="get" action="/00OE0000002uHmV" >
                    <B>C- Conversion Rate by Source</B>
                    <br/>
                    <B>Date Ranges:</B>
                    <br/>
                    Travel Date From (MM/DD/YYYY):
                    <input type="text" name="pv0" id="pv8" class="datepick"/><br />
                    Travel Date To (MM/DD/YYYY):
                    <input type="text" name="pv1" id="pv9" class="datepick"/>
                    <br />
                    <input type="submit" value="Conversion Rate" class="submit" />
                </form>
            </TD>
        </TR>
    </TABLE>
</apex:Page>

User-added image
User-added image
 
Amit Chaudhary 8Amit Chaudhary 8
Please check below post. How to pass filter value from VF page to Report
1) http://www.tgerm.com/2011/04/passing-params-to-reports-salesforce.html
2) http://pragmaticforce.blogspot.in/2011/08/passing-report-criteria-via-dynamic_9002.html
3) http://forceguru.blogspot.in/2010/11/passing-filter-value-in-reports-at.html

Now create two link which will redirect to a VFP, with the filter param value by which report will be filtered. Now this VFP will redirect to report URL, e.g https://....../<reportId>?pv0=paramValue. Value passed in pv0 will automatically become the filter value for the report. Now if I pass ?pv0=abc report will show me all account with name "abc" and if I pass ?pv0=xyz report will show me all account with name "xyz".


Like this if we have more than one filters then we can also pass values for them like pv0 , pv1 , pv2 and so on.

Let us know if this will help you

Thanks
Amit Chaudhary
 
Andrea SloanAndrea Sloan
Hi Amit:

Thank ou for replying but the links you sent me aren't relevent for the issue I'm having. As you could see in my form, I'm already redirecting the data input results to the URL of my report. I'm also specifying everything to the correct PV0, Pv1 and PV2. As I mentioned, everything passes on corrrectly when using the calendar picker as the input in the form. My Confirm Date, has the option of either entering a date as a calendar picker or as a combo box of picklist option that a user already has available to them to preselect. So when they decide to go with the text picklist option as a dynamic date such as "This Year", even though the input in the form works, nothing passes through to the report for that given input. Again, all passes through correctly when inputting the information via my Forms with calendar picker. I'm sure I'm missing one minor elemenet to combine calendar picker along with hte combo box that I'm doing incorrectly and I was hoping someone could point me where I went wrong ad suggest what to input instead. Perhaps I set up something incorrectly in the combobox setting but I don't know.