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
geeta garggeeta garg 

How to redirect the one page after page loading

I have vf page which is used to export data into csv format.But I want to redirect the page after loading and saving the csv file.
<apex:page standardController="Account" extensions="redirectme" cache="true" contentType="text/csv#ExportAccountdata.csv" language="en-US" > Id,Name,Phone
<apex:repeat value="{!acc}" var="account"> {!account.id},{!account.name},{!account.phone}
</apex:repeat>
</apex:page>
Controller of Vf page :-
public class redirectme {

    public redirectme(ApexPages.StandardController controller) {
    acc=[select id,name,phone from account];

    }

public list<account> acc{
get;
set;
}

    
    public pagereference redirect()
    {
    Pagereference pg=new pagereference('https://geeta-dev-ed.my.salesforce.com/001?fcf=00B28000003KuCF');
    pg.setredirect(true);
    return pg;
    }

}



 
shiva pendemshiva pendem
HI Geeta ,

Use Action attribute in <apex:page> component

<apex:page standardController="Account" extensions="redirectme" cache="true" contentType="text/csv#ExportAccountdata.csv" language="en-US" action="{!redirect}" > Id,Name,Phone
<apex:repeat value="{!acc}" var="account"> {!account.id},{!account.name},{!account.phone}
</apex:repeat>
</apex:page>


Thanks,
Shiva
geeta garggeeta garg
Hi Shiva,
I have already used action attribute. If i use action attribute ,Page will redirect to another page but Csv file is not downloaded.
So Please try it in your org.
Thanks,
Geeta Garg