0

When i click "preview" in the dev console, this page displays as i'd expect it too. however if I click to create a new product in Salesforce from within the Product object, the page never appears. Am i missing something?

 <apex:page standardController="Product2">
<apex:sectionHeader title="R&D Project Edit" subtitle="New R&D Project" />  
<apex:form >
    <apex:pageBlock>
        <apex:pageBlockSection columns="2" showHeader="true" title="R&D Project Detail" rendered="{!Product2.recordType.DeveloperName == 'Unavailable_R_D_Project'}">
            <apex:inputField Value="{!Product2.Name}" label="Project Name" / >
            <apex:inputField Value="{!Product2.R_D_Directorate__c}"/>              
            <apex:inputField Value="{!Product2.Status__c}"/>
            <apex:inputField Value="{!Product2.Expected_Next_Stage_Date__c}"/>
            <apex:inputField Value="{!Product2.R_D_Unique_ID__c}"/>
            <apex:inputField Value="{!Product2.Lifecycle_Status__c}"/>
            <apex:inputField Value="{!Product2.Project_Owner__c}"/>
            <br/>
            <apex:inputField Value="{!Product2.Alternative_Project_Contact__c}"/>
            <br/>
            <apex:inputField Value="{!Product2.Can_the_project_be_discussed_externally__c}"/>
            <br/>
            <apex:inputField Value="{!Product2.Looking_for_participants__c}"/>
        </apex:pageBlockSection>
                <apex:pageBlockSection columns="2" showHeader="true" title="Description Information">
                     <apex:inputField Value="{!Product2.Project_Description__c}"/>
                     <apex:inputField Value="{!Product2.Cluster_Area_Portfolio__c}"/>
                     <apex:inputField Value="{!Product2.Benefits_to_the_customer__c}"/>
                     <apex:inputField Value="{!Product2.Eligibility__c}"/>
                </apex:pageBlockSection>
                        <apex:pageBlockSection columns="2" showHeader="true" title="Service Information">
                            <apex:inputField Value="{!Product2.Risks__c}"/>
                            <apex:inputField Value="{!Product2.Include_in_Dashboard__c}"/>
                            <apex:inputField Value="{!Product2.Expected_Date_Service__c}"/>
                            <apex:inputField Value="{!Product2.Sector__c}"/>
                            <apex:inputField Value="{!Product2.Expected_Date_Alpha__c}"/>
                            <apex:inputField Value="{!Product2.Jisc_Directorate__c}"/>
                            <apex:inputField Value="{!Product2.Expected_Date_Beta__c}"/>
                        </apex:pageBlockSection>
                                <apex:pageBlockSection columns="2" showHeader="true" title="Progress Information">
                                    <apex:inputField Value="{!Product2.Level_of_Demand__c}"/>
                                    <apex:inputField Value="{!Product2.Feasibility__c}"/>
                                    <apex:inputField Value="{!Product2.Notes_on_Current_Progress__c}"/>
                                    <apex:inputField Value="{!Product2.Expected_Usefulness__c}"/>
                                </apex:pageBlockSection>
                                        <apex:pageBlockSection columns="2" showHeader="true" title="System Information">
                                            <apex:inputField Value="{!Product2.createdbyId}"/>
                                            <apex:inputField Value="{!Product2.lastmodifiedbyId}"/>
                                        </apex:pageBlockSection>
             <apex:pageBlockButtons location="bottom">
                 <apex:commandButton value="Save" action="{!save}" />
                 <apex:commandButton value="Cancel" action="{!cancel}" />
                 </apex:pageBlockButtons>
   </apex:pageBlock>

  • Have you overridden the New button to use your VisualForce page? – TSmith Nov 11 '16 at 15:57
  • haha no I haven't, how do i do that? @TSmith – Glenn Daly Nov 11 '16 at 15:59
2

You will need to override the New button for this object. Navigate to your object and take a look at the Buttons, Links, and Actions.

Click Edit beside New and choose Override With Visualforce Page. You will then have the option of which page you would like to use. enter image description here

  • The only problem with this @TSmith is that there are multiple record types the user can choose from when creating a new record, so when the user clicks "new" it should then display the record types available. And then when the user clicks Unavailable_R_D_Project it should go to the visualforce page? would this work in the same way? – Glenn Daly Nov 11 '16 at 16:06
  • This will solve the initial question you asked regarding why your page is displaying with Preview but not with New. I am not sure how you are supporting various RTs on initialisation of this page. – TSmith Nov 11 '16 at 16:09
  • When I click "New" from within the "Product2" object it provides me with 6 record types to create a new record from. I only want the visualforce page to display when creating a record of a certain record type. should i post a new question now this has been answered? – Glenn Daly Nov 11 '16 at 16:15
  • Isn't your page going to render itself depending on what RT you choose at that point? – TSmith Nov 11 '16 at 16:18
  • When I click on new, then choose the record type, it goes to the standard page (not the visualforce page) if i then press cancel, it takes me to the visualforce page, but it does this for all records? – Glenn Daly Nov 11 '16 at 16:20

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.