You need to sign in to do that
Don't have an account?
Ashok Kumar Nayak
Please suggest a test class for my controller...
public with sharing class LP_CreateNewCasePage_Controller
{
public String Id;
public Id ParentId;
public PageReference OtherRedirect(){
try{
System.debug('Selected RecordType is'+selectedrecordtype);
Id recTypeId = [SELECT id from RecordType WHERE id=:selectedrecordtype].id;
PageReference p = new PageReference('/' + Case.SObjectType.getDescribe().getKeyPrefix() + '/e');
Map<String, String> m = p.getParameters();
if((string)ApexPages.currentPage().getParameters().get('retURL').substring(1,4)!='500')
{
ParentId = ApexPages.currentPage().getParameters().get('retURL').substring(1,16);
Id=(string)ParentId;
if(Id.Startswith('003')){
m.putAll(ApexPages.currentPage().getParameters());
m.put('nooverride', '1');
m.put('RecordType',recTypeId);
p.setRedirect(true);
}
if(Id.Startswith('001')){
m.putAll(ApexPages.currentPage().getParameters());
m.put('nooverride', '1');
m.put('RecordType',recTypeId);
p.setRedirect(true);
}
return p;
}
else{
m.put('nooverride', '1');
m.put('RecordType',recTypeId);
p.setRedirect(true);
return p;
}
}
catch(Exception l_objEx)
{
String l_stMsg = 'Exception while redirecting to Case Creation Page.';
String l_stErrMessage = l_objEx.getTypeName()+': '+l_stMsg;
System.debug(l_stErrMessage);
return null;
}
}
}
{
public String Id;
public Id ParentId;
public PageReference OtherRedirect(){
try{
System.debug('Selected RecordType is'+selectedrecordtype);
Id recTypeId = [SELECT id from RecordType WHERE id=:selectedrecordtype].id;
PageReference p = new PageReference('/' + Case.SObjectType.getDescribe().getKeyPrefix() + '/e');
Map<String, String> m = p.getParameters();
if((string)ApexPages.currentPage().getParameters().get('retURL').substring(1,4)!='500')
{
ParentId = ApexPages.currentPage().getParameters().get('retURL').substring(1,16);
Id=(string)ParentId;
if(Id.Startswith('003')){
m.putAll(ApexPages.currentPage().getParameters());
m.put('nooverride', '1');
m.put('RecordType',recTypeId);
p.setRedirect(true);
}
if(Id.Startswith('001')){
m.putAll(ApexPages.currentPage().getParameters());
m.put('nooverride', '1');
m.put('RecordType',recTypeId);
p.setRedirect(true);
}
return p;
}
else{
m.put('nooverride', '1');
m.put('RecordType',recTypeId);
p.setRedirect(true);
return p;
}
}
catch(Exception l_objEx)
{
String l_stMsg = 'Exception while redirecting to Case Creation Page.';
String l_stErrMessage = l_objEx.getTypeName()+': '+l_stMsg;
System.debug(l_stErrMessage);
return null;
}
}
}
use below code.. but this not exact code for your test class..
you have to change according to your page
Note: in the below code you have to change the pag name insted of this "Yourpagenmae"
Hope this will help you
Thanks
karthik
Hi Karthik,
I tried with this, adding my page name. but its not getting covered at all.
I'm just autopopulating the account and contact while creating a case with a VF page overiden for the New Button for Case SObject.
Thanks & Regards
Ashok