You need to sign in to do that
Don't have an account?
Accessing related parent values when creating a child object from a related list
Hello, forum:
[Similar question to one I asked in a different thread...]
I've created a VF page for creating new child objects from a related list on a parent. This page has a pageBlock at the top of the page where parent values are displayed. The 'name' field of the parent displays just fine, but another custom field within the parent does not display.
I have this line in my VF page:
<apex:outputField id="projectName" value="{!Solicitor__c.SOL_Bidding_Opportunity__r.BO_Project_Name__c}"/>
But this field doesn't display.
My controller extension looks like this:
public class solicitorExtension { public solicitorExtension(ApexPages.StandardController controller) { Solicitor__c sol = (Solicitor__c)controller.getRecord(); //if you always create the child object through relatedList //parent should not be null if (sol.SOL_Bidding_Opportunity__c != null) { Bidding_Opportunity__c bo = [select BO_Bid_Due_Date_Time__c, BO_Project_Name__c from Bidding_Opportunity__c where id =: sol.SOL_Bidding_Opportunity__c limit 1]; sol.SOL_Bid_Due_Date_Time__c = bo.BO_Bid_Due_Date_Time__c; sol.SOL_Revision_Number__c = 'ORIG'; sol.SOL_Status__c = 'Prospective'; } } }
What am I doing wrong?
Thank you.
In your apex code, you are doing the query and assigning to the object "bo", but not to "Solicitor__c.SOL_Bidding_Opportunity__r".
If you add an extra assignment like below to the end of the if statement it should work.
sol.SOL_Bidding_Opportunity__r = bo;
Hi Guys,
thanks for the post. I'm in a similar situation but having two parents, here's my controller extension :
and the page :
but the IDE returns the following error : Save error: Unknown property 'Tests_to_run__cStandardController.st'
any suggestion ?
thanks in advance.
Alex