You need to sign in to do that
Don't have an account?
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;
}
}
<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;
}
}
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
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