You need to sign in to do that
Don't have an account?
Ab
Page redirection issue | redirect to VF or Standard case creation
Hello,
I have a VF and Apex like below
When the code enters the second loop:
My required use case is:
1) normal creation of case should proceed
2) VF page is not required at all
Problem now:
1)the record selection page is displayed but, when "continue" is clicked, it always redirects the user to the same link, hence a contunour loop..
i want to let the user carry on normally creation of case, not any way linked ot VF page ?
thanks for suggestion !
I have a VF and Apex like below
<apex:page standardController="Case" extensions="customClass" action="{!Redirect}" > </apex:page> public with sharing class customClass{ public PageReference Redirect(){ String usrProfileName = [SELECT Profile.Name FROM User WHERE Id = :Userinfo.getUserId()].Profile.Name; String hostname = ApexPages.currentPage().getHeaders().get('Host'); if(String.isNotBlank(usrProfileName)) { if(usrProfileName.equals('XYZ') || usrProfileName.equals('PQR)){ return null; //Continue the normal execution of VF page }else{ //PROBLEM: Explantion below pagereference pageref = new pagereference('https://'+hostname+'/'+'setup/ui/recordtypeselect.jsp?ent=Case&retURL=%2F500%2Fo&save_new_url=%2F500%2Fe%3FretURL%3D%252F500%252Fo'); pageref.setredirect(true); return pageref; } } return null; } }
When the code enters the second loop:
My required use case is:
1) normal creation of case should proceed
2) VF page is not required at all
Problem now:
1)the record selection page is displayed but, when "continue" is clicked, it always redirects the user to the same link, hence a contunour loop..
i want to let the user carry on normally creation of case, not any way linked ot VF page ?
thanks for suggestion !
Your code is working fine when it enters to the else part. Record type page opens and after clicking on continue it redirect to the normal new case detail page.
public with sharing class customClass{
public customClass(ApexPages.StandardController controller) {
}
public PageReference Redirect(){
String usrProfileName = [SELECT Profile.Name FROM User WHERE Id = :Userinfo.getUserId()].Profile.Name;
String hostname = ApexPages.currentPage().getHeaders().get('Host');
if(String.isNotBlank(usrProfileName))
{
if(usrProfileName.equals('XYZ') || usrProfileName.equals('PQR')){
return null; //Continue the normal execution of VF page
}else{ //PROBLEM: Explantion below
pagereference pageref = new pagereference('https://'+hostname+'/'+'setup/ui/recordtypeselect.jsp?ent=Case&retURL=%2F500%2Fo&save_new_url=%2F500%2Fe%3FretURL%3D%252F500%252Fo');
pageref.setredirect(true);
return pageref;
}
}
return null;
}
}