You need to sign in to do that
Don't have an account?
Richard Houston 20
Pass parent information to visualforce page when creating child record
Hi,
I'm having an issue getting a record's parent fields to display properly on a new visiualforce page. When I first create the visualforce page the parent ID (Opportunity.ID) is written into a lookup field on the child object record (Pursuit_Survey__c.Opportunity__c). This value returns and renders as expected when creating a new opportunity.
However, when I try and reference any other related fields on the opportunity I get either blanks, or in the case of dates, the system date/time.
Thanks for your help!
Richard
Controller extension
VF Page snippet
Opportunity name renders the lookup information. Howver the other fields are blank until after the record is saved. How do I get them to show before the record is saved?
I'm having an issue getting a record's parent fields to display properly on a new visiualforce page. When I first create the visualforce page the parent ID (Opportunity.ID) is written into a lookup field on the child object record (Pursuit_Survey__c.Opportunity__c). This value returns and renders as expected when creating a new opportunity.
However, when I try and reference any other related fields on the opportunity I get either blanks, or in the case of dates, the system date/time.
Thanks for your help!
Richard
Controller extension
public with sharing class SurveyParentIDExt{ public Pursuit_Survey__c PursuitChild{get;set;} public Opportunity ParentOpp{get;set;} public SurveyParentIDExt(ApexPages.StandardController controller){ PursuitChild=(Pursuit_Survey__c)controller.getRecord(); String oppid = (PursuitChild.Opportunity__c); String parentID = System.currentPagereference().getParameters().get('parentid'); if (parentID != null){ PursuitChild.Opportunity__c=parentid; } system.debug(PursuitChild.Opportunity__c); }
VF Page snippet
<apex:page standardController="Pursuit_Survey__c" extensions="SurveyParentIDExt"> <apex:pageBlock > <apex:pageMessages id="messages"></apex:pageMessages> <h2>Opportunity: <apex:outputfield value="{!Pursuit_Survey__c.Opportunity__c}" /> <br/><br/> Award Date: <apex:OutputField value="{!Pursuit_Survey__c.Opportunity__r.CloseDate}"></apex:OutputField> <br/><br/> Contract Value: <apex:outputField value="{!Pursuit_Survey__c.Opportunity__r.Contract_Value__c}"/> <br/><br/> Description: <apex:outputField value="{!Pursuit_Survey__c.Opportunity__r.Description}"/> <br/><br/> </apex:pageblock> </apex:page>
Opportunity name renders the lookup information. Howver the other fields are blank until after the record is saved. How do I get them to show before the record is saved?
that is change Pursuit_Survey__c to PursuitChild
As a common practice, if your question is answered, please choose 1 best answer.
But you can give every answer a thumb up if that answer is helpful to you.
Thanks