You need to sign in to do that
Don't have an account?

Get DeveloperName from recordtype by passing recordtypeid which is fetched from url.
This is my code:-
public class DispatcherContactNewController {
public DispatcherContactNewController(ApexPages.StandardController controller) {
this.controller = controller;
}
public PageReference Redir() {
PageReference newPage;
PageReference standardpage = New PageReference('/00Q/e?retURL=%2F00Q%2Fo&RecordType=012900000011wvV&ent=Lead&nooverride=1');
RecordType r;
r = [Select developerName from RecordType Where SobjectType='Lead' And id = :ApexPages.currentPage().getParameters().get('RecordType')];
if ( r.developerName == 'LeadVisualforcePage') {
System.debug('----------------------------------------------------------------------');
newPage = Page.leadtask;
return newPage;
} else {
System.debug('**********************************************************************');
return standardpage;
}
}
private final ApexPages.StandardController controller;
}
Can you check if you have any class saved by the name RecordType ?? If you find any, rename it and try it again!
Thanks,
balaji
All Answers
The code looks fine to me. Can you please specify what problem you are facing by using this code?
Thanks,
Pankaj
Thanks for replying Pankaj.
To be Specific the error I am getting is "Compile Error: Illegal assignment from List<RecordType> to RecordType at line 13 column 9"
List<RecordType> r = [Select developerName from RecordType Where SobjectType='Lead' And id = :ApexPages.currentPage().getParameters().get('RecordType') LIMIT 1];
Can you check if you have any class saved by the name RecordType ?? If you find any, rename it and try it again!
Thanks,
balaji
That was very simple @Balaji. Came through this solution on many forums. But I was confident enough that I have not created any RecordType class. However, checked and found an empty RecordType class. That might have been created unknowingly.
Thank you so much @Balaji.