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
BobBBobB 

Passing report variables from VF so they have no effect

I'm sure you'll all be pleased to know that my search is working and I won't be bugging you about that anymore. However, I still have one small problem.

 

I have a button in the search that links to a report:

          <apex:commandButton action="{!$Site.CurrentSiteUrl}/00OJ0000000O9cH?pv0={!contributorFname}&pv1={!contributorLname}&pv02=''" value="Run Report" rerender="results,debug" id="theReport"/>         

 and it works. Sort of, it does link and it does report. But only if contributorFname AND contributorLname have values that make sense to a "starts with" report filter. Is there a way to pass values such that the filter is ignored?

 

Assuming the answer to that is no... I'm doing this to facilitate exporting the resulting search table. Is there a way to do that in Visualforce? I apologize if this is a basic duh question.

 

Thanks... Bob

 

 

 

Best Answer chosen by Admin (Salesforce Developers) 
bob_buzzardbob_buzzard

Remove the line break after the apex:page tag.  The following format worked for me:

 

<apex:page controller="ContributionsSearchController_v12"  cache="true" 
contentType="text/plain/#test.csv">Name,Amount,Date,Contributor First Name,Contributor Last Name,VFP Network,City,State,Zip,Cycle,MOC First Name,MOC Last Name

 

All Answers

bob_buzzardbob_buzzard

Not really.  If you leave those values blank, you are telling the filters they need to start with a blank value.  You'll need to have a cloned version of the report that doesn't take any filter values and determine in your VF code which one to hit.

 

Are you looking to export as csv?  If so, you can do this by generating csv in your page and setting the content type.  Here's a noddy example:

 

<apex:page standardcontroller="Account" recordsetvar="accounts" cache="true" 
contentType="text/plain/#test.csv">
Name,City\n
<apex:repeat value="{!accounts}" var="acc">
{!acc.name},{!acc.BillingCity}
</apex:repeat>
</apex:page>

 

 

 

Bob BaileyBob Bailey

Hi Bob,

 

I think this is the right track. CSV will be fine. What I have now is a page with a table in it that I want to export. There are other tables on the page.

 

I tried creating a button that called a simple page much like this code you shared. It did not work very well for me. The logic is already in place to generate the table for export and it has a custom SOQL statement built on parameters.

 

I'll tinker with it some more.

 

Thanks.... Bob

Bob BaileyBob Bailey

Hi Bob, So far, so good. Here's the code as modified:

<apex:page controller="ContributionsSearchController_v12"  cache="true" 
contentType="text/plain/#test.csv">
Name,Amount,Date,Contributor First Name,Contributor Last Name,VFP Network,City,State,Zip,Cycle,MOC First Name,MOC Last Name
<apex:repeat value="{!contributions}" var="contribution">
    {!contribution.name},{!contribution.Contribution_Amount__c},{!contribution.Contribution_Date__c},{!contribution.Contributor__r.firstname},{!contribution.Contributor__r.lastname},{!contribution.Contributor__r.VFP_Member__c},{!contribution.Contributor_City__c},{!contribution.Contributor_State__c},{!contribution.Contributor_Zip__c},{!contribution.Election_Cycle__c},{!contribution.MOC__r.firstname} ,{!contribution.MOC__r.lastname}                       ,
</apex:repeat>
</apex:page>

 

Turns out that the \n after the header row isn't needed. BUT... I'm getting an extra row that's blank at the start of the output. It's not using the "N" at the beginning as a newline. Any ideas on how to get rid of this?

 

Thanks again. You've been very helpful.

 

...Bob

 

bob_buzzardbob_buzzard

Remove the line break after the apex:page tag.  The following format worked for me:

 

<apex:page controller="ContributionsSearchController_v12"  cache="true" 
contentType="text/plain/#test.csv">Name,Amount,Date,Contributor First Name,Contributor Last Name,VFP Network,City,State,Zip,Cycle,MOC First Name,MOC Last Name

 

This was selected as the best answer
Bob BaileyBob Bailey

Thanks, Bob.

 

That did it. You are the man.

 

...Bob

 

PS How come I can't mark this as the solution?

BobBBobB

It seems I have two accounts here. I guess only the OP can mark solution?

bob_buzzardbob_buzzard

Evil mods like me can mark or unmark as the solution too >:)