You need to sign in to do that
Don't have an account?
Matthew Birckbichler
VisualForce Page to create new custom object from button in Opportunity related list
I will start of by saying, I am pretty familiar with APEX, but brand new toVisualForce.
I have a custom objects called Opportunity_Contact__c, in the related list for this on Opportunity, I need to replace the current 'new' Button with a custom button to a VF page.
First issue I am having is, if I use the standard controller 'Opportunity_Contact__c', when I click the button, I recieve this...
'Id value 00655000004MBYc is not valid for the Opportunity_Contact__c standard controller'.
I realize that this is because it is passing the Opportunity ID into the VP page, and I am not using the Opportunity standard controller, but I am unsure how to move forward.
My code thus far :
I have a custom objects called Opportunity_Contact__c, in the related list for this on Opportunity, I need to replace the current 'new' Button with a custom button to a VF page.
First issue I am having is, if I use the standard controller 'Opportunity_Contact__c', when I click the button, I recieve this...
'Id value 00655000004MBYc is not valid for the Opportunity_Contact__c standard controller'.
I realize that this is because it is passing the Opportunity ID into the VP page, and I am not using the Opportunity standard controller, but I am unsure how to move forward.
My code thus far :
<apex:page standardController="Opportunity_Contact__c" extensions="createOpportunityContactExtension"> <apex:form > <apex:pageBlock title="Create New Opportunity Contact" mode="new"> <apex:pageBlockButtons > <apex:commandButton action="{!save}" value="Save"/> <apex:commandButton action="{!cancel}" value="Cancel"/> </apex:pageBlockButtons> <apex:pageBlockSection columns="1"> <apex:inputField value="{!Opportunity_Contact__c.Opportunity__c}"/> </apex:pageBlockSection> </apex:pageBlock> </apex:form> </apex:page>
public class createOpportunityContactExtension { private final Opportunity_Contact__c oppCon; public createOpportunityContactExtension(ApexPages.StandardController stdController){ this.oppCon = (Opportunity_Contact__c)stdController.getRecord(); } }
All Answers