iam facing problem using visual force page in my lead there a re four record types
one,two,three,four.
if i click new button->then it shows the record type selection page->then i select one ->it redirects to a visual force page name leadTest. because i over ridden new button with visual force page.
if i click two it should go to a standard page record type for two and a page layout is also assigned for it.
if i click three it should go to a standard page record type for three and a page layout is also assigned for it.
same like for four.
but here it is not redirecting to the standard page when iam passing the url in my controller .
String selectedRecordType = ApexPages.currentPage().getParameters().get('RecordType'); if (selectedRecordType == 'One')// id will be there return Page.LeadTest.setRedirect(True); else if(selectedRecordType == 'Two') return new PageReference('/00Q/e?retURL=%2F00Q%2Fo&RecordType=012O00000000Acd&ent=Lead'); else if(selectedRecordType == 'Three') return new PageReference('/00Q/e?retURL=%2F00Q%2Fo&RecordType=012O00000000Acn&ent=Lead');
Thanks guys finally i found out solution with the help of my colleague Anoop.
public PageReference redirectToPage() {
String selectedRecordType = ApexPages.currentPage().getParameters().get('RecordType');
Id id=selectedRecordType;
String csRtId=RIIUtility.getRecordTypeId('Home Loan',new Lead());
String carRtId=RIIUtility.getRecordTypeId('Car Loan',new Lead());
String crRtId=RIIUtility.getRecordTypeId('Credit Card',new Lead());
if (selectedRecordType == csRtId){
return Page.LeadTest.setRedirect(True);
}
if(id == carRtId) {
PageReference p = new PageReference('/00Q/e?retURL=%2F00Q%2Fo&RecordType='+carRtId+'&ent=Lead ');
p.getParameters().put('nooverride','1');
return p;
}
if(id == crRtId) {
PageReference p = new PageReference('/00Q/e?retURL=%2F00Q%2Fo&RecordType='+crRtId+'&ent=Lead ');
p.getParameters().put('nooverride','1');
return p;
}
else
return null;
}
All Answers
Add the parameter nooverride
p.getParameters().put('nooverride','1');
Code For ref.
else if(selectedRecordType == 'Two')
{
p = new PageReference(/00Q/e?retURL=%2F00Q%2Fo&RecordType=012O00000000Acd&ent=Lead');
p.getParameters().put('nooverride','1');
return p;
}
else if(selectedRecordType == 'Three')
{
p = new PageReference(/00Q/e?retURL=%2F00Q%2Fo&RecordType=012O00000000Acn&ent=Lead');
p.getParameters().put('nooverride','1');
return p;
}
else if(selectedRecordType == 'Four')
{
p = new PageReference(/00Q/e?retURL=%2F00Q%2Fo&RecordType=012O000000003ds&ent=Lead');
p.getParameters().put('nooverride','1');
return p;
}
Hi SRK
i used ur code but it is not going to the standard page it still showing the visual force page .
is this the problem with over ridding the new button with that visual force page.
Thanks
Anil.B
Hi
Can you plz.. share the new code
as you mention that you add the ('nooverride', '1').
& yes it is bcoz of overrind new button but nooverride = 1 is parameter is used to overcome the overriding
Hi SRK
This is my code :-
Thanks guys finally i found out solution with the help of my colleague Anoop.
public PageReference redirectToPage() {
String selectedRecordType = ApexPages.currentPage().getParameters().get('RecordType');
Id id=selectedRecordType;
String csRtId=RIIUtility.getRecordTypeId('Home Loan',new Lead());
String carRtId=RIIUtility.getRecordTypeId('Car Loan',new Lead());
String crRtId=RIIUtility.getRecordTypeId('Credit Card',new Lead());
if (selectedRecordType == csRtId){
return Page.LeadTest.setRedirect(True);
}
if(id == carRtId) {
PageReference p = new PageReference('/00Q/e?retURL=%2F00Q%2Fo&RecordType='+carRtId+'&ent=Lead ');
p.getParameters().put('nooverride','1');
return p;
}
if(id == crRtId) {
PageReference p = new PageReference('/00Q/e?retURL=%2F00Q%2Fo&RecordType='+crRtId+'&ent=Lead ');
p.getParameters().put('nooverride','1');
return p;
}
else
return null;
}