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

Help with Record Type Redirect
Dear all, I`m new to apex and I need help with issue below. I have a "New Case" custom button on Opportunity record which allows me to create Case. When clicked on "New Case" button, I can select record type and page gets redirected to standard page or visualforce page using redirect class below. Code works fine but I`m unable to auto-populate fields when record type with standard page is selected. Fields are not getting auto populated the way it happens with standard functionality. For example, I`m not able to auto-populate Opportunity Name, Stage or Close Date while creating new case record. Can someone please help? Any help is much appreciated. Thank you!
Redirect VF page
Redirect class
Redirect VF page
<apex:page standardController="Case" extensions="Redirect" action="{!Redirect}"> </apex:page>
Redirect class
public with sharing class Redirect{ private Id id; private ApexPages.StandardController controller; public String retURL {get; set;} public String saveNewURL {get; set;} public String rType {get; set;} public String cancelURL {get; set;} public String ent {get; set;} public String confirmationToken {get; set;} public Redirect(ApexPages.StandardController controller) { this.controller = controller; retURL = ApexPages.currentPage().getParameters().get('retURL'); rType = ApexPages.currentPage().getParameters().get('RecordType'); cancelURL = ApexPages.currentPage().getParameters().get('cancelURL'); ent = ApexPages.currentPage().getParameters().get('ent'); confirmationToken = ApexPages.currentPage().getParameters().get('_CONFIRMATIONTOKEN'); saveNewURL = ApexPages.currentPage().getParameters().get('save_new_url'); } public PageReference redirect(){ PageReference returnURL; // Redirect if Record Type corresponds to custom VisualForce page if(rType == '0121b0000009t60') { returnURL = new PageReference('/apex/vfcasepage'); } else { returnURL = new PageReference('/500/e?nooverride=1'); } returnURL.getParameters().put('retURL', retURL); returnURL.getParameters().put('RecordType', rType); returnURL.getParameters().put('cancelURL', cancelURL); returnURL.getParameters().put('ent', ent); returnURL.getParameters().put('_CONFIRMATIONTOKEN', confirmationToken); returnURL.getParameters().put('save_new_url', saveNewURL); returnURL.getParameters().put('nooverride', '1'); returnURL.setRedirect(true); return returnURL; } public PageReference cancel() { PageReference pr = new PageReference('/500/o'); pr.setRedirect(true); return pr; } }
This should help you get parameter value.
All Answers
This should help you get parameter value.