You need to sign in to do that
Don't have an account?
Amita Tatar
Override Record Type selection with custom page
Hi all,
I want to know whether we can override a particular record type page with a custom VF page? If yes how can we do that. Please help me
I want to know whether we can override a particular record type page with a custom VF page? If yes how can we do that. Please help me
You will have to override your New Button on the object and select a VF page with a controller ( refer link ) where to set your conditional redirection.
Also, you need to keep your "Skip record type seletion page " checkbox unchecked when you override the new button.
See link for reference:
http://www.topalovich.com/2009/08/force-com-tip-new-button-override-to-assign-visualforce-page-to-specific-record-type-using-native-apex-code/
Mark solved if this helps.
Regards
Medhya Mahajan
The code seems to be correct. Can you provide me further details ?
When you Select the record type and move to the VF ( Can you see the Record Type in the URL ) ??
Regards
Medhya Mahajan
yes i am able to see the record type in the URL,but its not displaying on the page properly. Also i have picklist values for each record type. They are also not retrieved properly
I have overriden the new button. Where is the checkbox for "skip record type selection" page
It's available on the Override option of new button.
Also, can you share the code for VF with me ???
Change you code of controller like this :
You were not assigning the value to varibale recordType and your are redirecting based on that only.
Hope this helps.
Regards
Medhya Mahajan
I tried with this code. Its still the same
As I am stucking the same issue,when i select the particular record type the cutsom vf page should be display but its not getting.
I am referring this link:https://developer.salesforce.com/forums#!/feedtype=SINGLE_QUESTION_SEARCH_RESULT&id=906F0000000DC4AIAW
Please find the code:
public class opportunityinsert {
public boolean activeStats {set;get;}
public string name {set;get;}
public decimal amount {set;get;}
public List<Selectoption> type {set;get;}
public List<Selectoption> leadsource {set;get;}
public List<Selectoption> StageName {set;get;}
public string NextStep {set;get;}
public string OrderNumber {set;get;}
public string CurrentGenerator {set;get;}
public string TrackingNumber {set;get;}
public string MainCompetitor {set;get;}
public List<Selectoption> Deliverystatus {set;get;}
public date dat {set;get;}
public decimal Probability {set;get;}
public string Description {set;get;}
public string s {set;get;}
public string t {set;get;}
public string u {set;get;}
public string v {set;get;}
public opportunityinsert(Apexpages.StandardController controller){
Opportunity op = new Opportunity();
op.Amount = amount;
op.CloseDate = dat;
op.Name = name;
op.NextStep = NextStep;
op.Probability = Probability;
StageName=new List<SelectOption>();
StageName.add(new SelectOption('--None--','--None--'));
StageName.add(new SelectOption('Prospecting','Prospecting'));
StageName.add(new SelectOption('Qualification','Qualification'));
StageName.add(new SelectOption('Needs Analysis','Needs Analysis'));
StageName.add(new SelectOption('Value Proposition','Value Proposition'));
StageName.add(new SelectOption('Id. Decision Makers','Id. Decision Makers'));
StageName.add(new SelectOption('Perception Analysis','Perception Analysis'));
StageName.add(new SelectOption('Proposal/Price Quote','Proposal/Price Quote'));
StageName.add(new SelectOption('Negotiation/Review','Negotiation/Review'));
StageName.add(new SelectOption('Closed Won','Closed Won'));
StageName.add(new SelectOption('Closed Lost','Closed Lost'));
type=new List<SelectOption>();
type.add(new SelectOption('--None--','--None--'));
type.add(new SelectOption('Existing Customer - Upgrade','Existing Customer - Upgrade'));
type.add(new SelectOption('Existing Customer - Replacement','Existing Customer - Replacement'));
type.add(new SelectOption('Existing Customer - Downgrade','Existing Customer - Downgrade'));
type.add(new SelectOption('New Customer','New Customer'));
leadsource=new List<SelectOption>();
leadsource.add(new SelectOption('--None--','--None--'));
leadsource.add(new SelectOption('Web','Web'));
leadsource.add(new SelectOption('Phone Inquiry','Phone Inquiry'));
leadsource.add(new SelectOption('Partner Referral','Partner Referral'));
leadsource.add(new SelectOption('Purchased List','Purchased List'));
leadsource.add(new SelectOption('Other','Other'));
op.OrderNumber__c = OrderNumber;
op.CurrentGenerators__c = CurrentGenerator;
op.MainCompetitors__c = MainCompetitor;
Deliverystatus=new List<SelectOption>();
Deliverystatus.add(new SelectOption('--None--','--None--'));
Deliverystatus.add(new SelectOption('In progress','In progress'));
Deliverystatus.add(new SelectOption('Yet to begin','Yet to begin'));
Deliverystatus.add(new SelectOption('Completed','Completed'));
op.TrackingNumber__c = TrackingNumber;
op.Description = Description;
}
public void saveMe(){
Opportunity Op= new Opportunity();
Op.Amount = amount;
Op.IsPrivate = activeStats;
Op.CloseDate = dat;
Op.Name = name;
Op.NextStep = NextStep;
Op.StageName = s;
Op.Type = t;
Op.Probability = Probability;
Op.LeadSource = u;
Op.OrderNumber__c = OrderNumber;
Op.CurrentGenerators__c = CurrentGenerator;
Op.MainCompetitors__c = MainCompetitor;
Op.DeliveryInstallationStatus__c = v;
Op.TrackingNumber__c = TrackingNumber;
Op.Description = Description;
insert Op;
apexpages.Message msg = new apexpages.Message(apexpages.Severity.CONFIRM, 'Record Inserted Successfully..');
apexpages.addMessage(msg);
amount = null;
activeStats = null;
dat = null;
name = null;
NextStep = null;
s = null;
t = null;
Probability = null;
u = null;
OrderNumber = null;
CurrentGenerator = null;
MainCompetitor = null;
v = null;
TrackingNumber = null;
Description = null;
}
public void Cancel(){
amount = null;
activeStats = null;
dat = null;
name = null;
NextStep = null;
s = null;
t = null;
Probability = null;
u = null;
OrderNumber = null;
CurrentGenerator = null;
MainCompetitor = null;
v = null;
TrackingNumber = null;
Description = null;
apexpages.Message msg = new apexpages.Message(apexpages.Severity.ERROR,'Please Try Again');
apexpages.addMessage(msg);
}
public pagereference redirectPage(){
Opportunity opp=new Opportunity();
PageReference oppPage ;
if(opp.recordTypeId=='0127F000000BbjNQAS')// Record type Id
{
oppPage = new PageReference('/apex/opportunityinsert?core.apexpages.request.devconsole=1' );
oppPage.setRedirect(true);
}
return oppPage;
}
}
VF page
========
<apex:page standardController="Opportunity" extensions="opportunityinsert" docType="html-5.0" action="{!redirectPage}">
<apex:form >
<apex:sectionHeader title="Opportunity Edit" subtitle="New Opportunity" help="https://help.salesforce.com/articleView?err=1&id=opportunities.htm&type=5"/>
<apex:pageBlock title="Opportunity Edit" mode="edit">
<apex:pageMessages ></apex:pageMessages>
<apex:pageBlockButtons location="both">
<apex:commandButton value="Save" action="{!saveMe}"/>
<apex:actionStatus id="actStatusId" >
<apex:facet name="start" >
<apex:image url="https://kberkery.com/wp-content/uploads/2017/08/site_loading.gif" height="50" width="50"/>
</apex:facet>
</apex:actionStatus>
<apex:commandButton value="Save & New" />
<apex:commandButton value="Cancel" action="{!Cancel}"/>
</apex:pageBlockButtons>
<apex:pageBlockSection collapsible="false" columns="2" title="Opportunity Information">
<apex:pageBlockSectionItem >
<apex:outputLabel value="Opportunity Owner"/>
<apex:outputText value="{!$User.FirstName&' '&$User.LastName}">
</apex:outputText>
</apex:pageBlockSectionItem>
<apex:pageBlockSectionItem >
<apex:outputLabel value="Amount"/>
<apex:inputText value="{!amount}"/>
</apex:pageBlockSectionItem>
<apex:pageBlockSectionItem >
<apex:outputLabel value="Private"/>
<apex:inputCheckbox value="{!activeStats}"/>
</apex:pageBlockSectionItem>
<apex:pageBlockSectionItem >
<apex:outputLabel value="Close Date"/>
<apex:outputPanel>
<div class="requiredInput">
<div class="requiredBlock"></div>
<apex:input type="date" value="{!dat}" required="true"/>
</div>
</apex:outputPanel>
</apex:pageBlockSectionItem>
<apex:pageBlockSectionItem >
<apex:outputLabel value="Opportunity Name" />
<apex:outputPanel>
<div class="requiredInput">
<div class="requiredBlock"></div>
<apex:inputText value="{!name}"/>
</div>
</apex:outputPanel>
</apex:pageBlockSectionItem>
<apex:pageBlockSectionItem >
<apex:outputLabel value="Next Step"/>
<apex:inputText value="{!NextStep}"/>
</apex:pageBlockSectionItem>
<apex:pageBlockSectionItem >
<apex:outputLabel value="Account Name"/>
<apex:inputField value="{!Opportunity.accountId}"/>
</apex:pageBlockSectionItem>
<apex:pageBlockSectionItem >
<apex:outputLabel value="Stage"/>
<apex:outputPanel>
<div class="requiredInput">
<div class="requiredBlock"></div>
<apex:selectList size="1" value="{!s}">
<apex:selectOptions value="{!StageName}"/>
</apex:selectList>
</div>
</apex:outputPanel>
</apex:pageBlockSectionItem>
<apex:pageBlockSectionItem >
<apex:outputLabel value="Type"/>
<apex:selectList size="1" value="{!t}">
<apex:selectOptions value="{!type}"/>
</apex:selectList>
</apex:pageBlockSectionItem>
<apex:pageBlockSectionItem >
<apex:outputLabel value="Probability (%)"/>
<apex:inputText value="{!Probability}"/>
</apex:pageBlockSectionItem>
<apex:pageBlockSectionItem >
<apex:outputLabel value="Lead Source"/>
<apex:selectList size="1" value="{!u}">
<apex:selectOptions value="{!Leadsource}"/>
</apex:selectList>
</apex:pageBlockSectionItem>
<apex:pageBlockSectionItem >
<apex:outputLabel value="Primary Campaign Source"/>
<apex:inputField value="{!Opportunity.campaignid}"/>
</apex:pageBlockSectionItem>
</apex:pageBlockSection>
<apex:pageBlockSection collapsible="false" columns="2" title="Additional Information">
<apex:pageBlockSectionItem >
<apex:outputLabel value="Order Number"/>
<apex:inputText value="{!OrderNumber}"/>
</apex:pageBlockSectionItem>
<apex:pageBlockSectionItem >
<apex:outputLabel value="Main Competitor(s)"/>
<apex:inputText value="{!MainCompetitor}"/>
</apex:pageBlockSectionItem>
<apex:pageBlockSectionItem >
<apex:outputLabel value="Current Generator(s)"/>
<apex:inputText value="{!CurrentGenerator}"/>
</apex:pageBlockSectionItem>
<apex:pageBlockSectionItem >
<apex:outputLabel value="Delivery/Installation Status"/>
<apex:selectList size="1" value="{!v}">
<apex:selectOptions value="{!Deliverystatus}"/>
</apex:selectList>
</apex:pageBlockSectionItem>
<apex:pageBlockSectionItem >
<apex:outputLabel value="Tracking Number"/>
<apex:inputText value="{!TrackingNumber}"/>
</apex:pageBlockSectionItem>
</apex:pageBlockSection>
<apex:pageBlockSection collapsible="false" columns="2" title="Description Information">
<apex:pageBlockSectionItem >
<apex:outputLabel value="Description"/>
<apex:inputTextarea value="{!Description}" cols="70" rows="6"/>
</apex:pageBlockSectionItem>
</apex:pageBlockSection>
</apex:pageBlock>
</apex:form>
</apex:page>
===========