You need to sign in to do that
Don't have an account?
Code+1
Page reference not working
Hello All,
After save of the record, I would like to redirect my Visual force page to custom object created..
Save is happening ... But the page is not getting redirected to the custom object...
I am using the below code
PageReference reference=new PageReference('https://cs18.salesforce.com/a0U/o');
reference.setRedirect(true);
return reference;
Below is the Full Code ..
VF Page -
<apex:page standardcontroller="BIA__c" extensions="BIAcontroller" sidebar="false">
<apex:messages style="color:blue"></apex:messages>
<apex:form id="theform">
<apex:pageblock mode="edit">
<apex:pageBlockSection title="Business Impact Analysis Information">
<apex:inputField id="opportunityName" value="{!account.name}" />
<apex:inputField id="opportunityName1" value="{!account.Date_of_BIA_Meeting__c}"/>
<apex:inputField id="opportunityName2" value="{!account.Manager__c}"/>
<apex:inputField id="opportunityName3" value="{!account.Department_BC_Coordinator__c}"/>
<apex:inputField id="opportunityName4" value="{!account.Backup_BC_Coordinator__c}"/>
<apex:inputField id="opportunityName5" value="{!account.Custodian__c}"/>
<apex:inputField id="opportunityName6" value="{!account.Prepared_by__c}"/>
<apex:inputField id="opportunityName7" value="{!account.Endorsed_by__c}"/>
<apex:inputField id="opportunityName8" value="{!account.Approved_by__c}"/>
</apex:pageBlockSection>
<apex:pageblockSection title="Team Search" >
<apex:inputfield value="{!objAct.CoE__c}" />
<apex:inputfield value="{!objAct.Department__c}" />
<apex:inputfield value="{!objAct.OpCo__c }" />
</apex:pageblockSection>
<center> <apex:commandButton value="Search" action="{!search}" rerender="theform" /> </center>
</apex:pageblock>
<apex:pageBlock >
<apex:pageBlockButtons >
<apex:commandButton value="Process Selected" action="{!processSelected}" rerender="table" />
</apex:pageBlockButtons>
<apex:pageBlockTable value="{!MSAWrapperList}" var="obj" id="table">
<apex:column >
<apex:inputCheckbox value="{!obj.selected}"/>
</apex:column>
<apex:column value="{!obj.msaObj.Name}" />
</apex:pageBlockTable>
</apex:pageBlock>
</apex:form>
</apex:page>
Controller --
public class BIAcontroller
{
public BIAcontroller(ApexPages.StandardController controller) {
account=new BIA__c();
bia=new BIA__c();
//contact=new SOC__c();
opportunity=new Team__c();
records=new List<Team__c>();
objAct=new Team__c();
msawrapperlist=new List<MSAWrapper>();
}
public BIA__c account{set;get;}
public BIA__c bia{get;set;}
//public SOC__c contact{set;get;}
public Team__c opportunity{set;get;}
public List<Team__c> records{get;set;}
public Team__c objAct{get;set;}
public List<MSAWrapper> MSAWrapperList {get; set;}
public List<Team__c > selectedMSA = new List<Team__c >();
public List<Team__c > TeamssToUpdate = new List<Team__c >{};
public BIA__c getAccount() {
if(account == null) account = new BIA__c ();
return account;
}
public pagereference search()
{
MSAWrapperList.clear();
records=[Select ID,Name,CoE__c,BIA__c,Department__c,OpCo__c from Team__c where CoE__c=: objAct.CoE__c and Department__c=: objAct.Department__c];
for(Team__c obj : records)
{
MSAWrapperList.add( new MSAWrapper(obj) );
}
return null;
}
public PageReference processSelected()
{
account.Name = account.Name;
account.Date_of_BIA_Meeting__c= account.Date_of_BIA_Meeting__c;
account.Manager__c= account.Manager__c;
account.Department_BC_Coordinator__c= account.Department_BC_Coordinator__c;
account.Backup_BC_Coordinator__c= account.Backup_BC_Coordinator__c;
account.Custodian__c= account.Custodian__c;
account.Prepared_by__c= account.Prepared_by__c;
account.Endorsed_by__c= account.Endorsed_by__c;
account.Approved_by__c= account.Approved_by__c;
insert account;
for(MSAWrapper cCon: MSAWrapperList )
{
if(cCon.selected == true)
{
selectedMSA.add(cCon.msaObj);
}
}
for(Team__c msa: selectedMSA)
{
system.debug(msa);
msa.BIA__c= account.id;
TeamssToUpdate.add(msa);
}
update TeamssToUpdate;
// return null;
system.debug('11111');
PageReference reference=new PageReference('https://cs18.salesforce.com/a0U/o');
system.debug('22222');
reference.setRedirect(true);
system.debug('33333');
return reference;
}
public class MSAWrapper
{
public Team__c msaObj {get; set;}
public Boolean selected {get; set;}
public MSAWrapper(Team__c c) {
msaObj = c;
selected = false;
}
}
}
Please help..
Thanks..
After save of the record, I would like to redirect my Visual force page to custom object created..
Save is happening ... But the page is not getting redirected to the custom object...
I am using the below code
PageReference reference=new PageReference('https://cs18.salesforce.com/a0U/o');
reference.setRedirect(true);
return reference;
Below is the Full Code ..
VF Page -
<apex:page standardcontroller="BIA__c" extensions="BIAcontroller" sidebar="false">
<apex:messages style="color:blue"></apex:messages>
<apex:form id="theform">
<apex:pageblock mode="edit">
<apex:pageBlockSection title="Business Impact Analysis Information">
<apex:inputField id="opportunityName" value="{!account.name}" />
<apex:inputField id="opportunityName1" value="{!account.Date_of_BIA_Meeting__c}"/>
<apex:inputField id="opportunityName2" value="{!account.Manager__c}"/>
<apex:inputField id="opportunityName3" value="{!account.Department_BC_Coordinator__c}"/>
<apex:inputField id="opportunityName4" value="{!account.Backup_BC_Coordinator__c}"/>
<apex:inputField id="opportunityName5" value="{!account.Custodian__c}"/>
<apex:inputField id="opportunityName6" value="{!account.Prepared_by__c}"/>
<apex:inputField id="opportunityName7" value="{!account.Endorsed_by__c}"/>
<apex:inputField id="opportunityName8" value="{!account.Approved_by__c}"/>
</apex:pageBlockSection>
<apex:pageblockSection title="Team Search" >
<apex:inputfield value="{!objAct.CoE__c}" />
<apex:inputfield value="{!objAct.Department__c}" />
<apex:inputfield value="{!objAct.OpCo__c }" />
</apex:pageblockSection>
<center> <apex:commandButton value="Search" action="{!search}" rerender="theform" /> </center>
</apex:pageblock>
<apex:pageBlock >
<apex:pageBlockButtons >
<apex:commandButton value="Process Selected" action="{!processSelected}" rerender="table" />
</apex:pageBlockButtons>
<apex:pageBlockTable value="{!MSAWrapperList}" var="obj" id="table">
<apex:column >
<apex:inputCheckbox value="{!obj.selected}"/>
</apex:column>
<apex:column value="{!obj.msaObj.Name}" />
</apex:pageBlockTable>
</apex:pageBlock>
</apex:form>
</apex:page>
Controller --
public class BIAcontroller
{
public BIAcontroller(ApexPages.StandardController controller) {
account=new BIA__c();
bia=new BIA__c();
//contact=new SOC__c();
opportunity=new Team__c();
records=new List<Team__c>();
objAct=new Team__c();
msawrapperlist=new List<MSAWrapper>();
}
public BIA__c account{set;get;}
public BIA__c bia{get;set;}
//public SOC__c contact{set;get;}
public Team__c opportunity{set;get;}
public List<Team__c> records{get;set;}
public Team__c objAct{get;set;}
public List<MSAWrapper> MSAWrapperList {get; set;}
public List<Team__c > selectedMSA = new List<Team__c >();
public List<Team__c > TeamssToUpdate = new List<Team__c >{};
public BIA__c getAccount() {
if(account == null) account = new BIA__c ();
return account;
}
public pagereference search()
{
MSAWrapperList.clear();
records=[Select ID,Name,CoE__c,BIA__c,Department__c,OpCo__c from Team__c where CoE__c=: objAct.CoE__c and Department__c=: objAct.Department__c];
for(Team__c obj : records)
{
MSAWrapperList.add( new MSAWrapper(obj) );
}
return null;
}
public PageReference processSelected()
{
account.Name = account.Name;
account.Date_of_BIA_Meeting__c= account.Date_of_BIA_Meeting__c;
account.Manager__c= account.Manager__c;
account.Department_BC_Coordinator__c= account.Department_BC_Coordinator__c;
account.Backup_BC_Coordinator__c= account.Backup_BC_Coordinator__c;
account.Custodian__c= account.Custodian__c;
account.Prepared_by__c= account.Prepared_by__c;
account.Endorsed_by__c= account.Endorsed_by__c;
account.Approved_by__c= account.Approved_by__c;
insert account;
for(MSAWrapper cCon: MSAWrapperList )
{
if(cCon.selected == true)
{
selectedMSA.add(cCon.msaObj);
}
}
for(Team__c msa: selectedMSA)
{
system.debug(msa);
msa.BIA__c= account.id;
TeamssToUpdate.add(msa);
}
update TeamssToUpdate;
// return null;
system.debug('11111');
PageReference reference=new PageReference('https://cs18.salesforce.com/a0U/o');
system.debug('22222');
reference.setRedirect(true);
system.debug('33333');
return reference;
}
public class MSAWrapper
{
public Team__c msaObj {get; set;}
public Boolean selected {get; set;}
public MSAWrapper(Team__c c) {
msaObj = c;
selected = false;
}
}
}
Please help..
Thanks..
If you want to redirect on record then please use below code:-
If you want to redirect to tab then please use below code
Please mark this as solution if this will help you
All Answers
Please refer this.
If you want to redirect on record then please use below code:-
If you want to redirect to tab then please use below code
Please mark this as solution if this will help you
even after using return new PageReference('/'+obj.id); it is not getting redirected to the detail page of created record.
I've kept system.debug statement just before the return statement to print the obj.Id . It prints the Id there.
If I copy this Id and manually append in browser's address bar , the record is opening.