You need to sign in to do that
Don't have an account?
pq100
Display Data from parent record on child VF layout
Hi
I'm using an extension to display data from the parent record (Site__c) on my VF page, this works correctly when i click on an existing record (Investment__c) in the related list, however, when i add a new Investment__c i get the following error:
System.QueryException: List has no rows for assignment to SObject
I'm guessing this is becausethe Id isn't available at this point ofr the new record. So does anyoneknow how i can get round this?
Code excerpt below, Thanks for any suggestions!
Paul
//get data from Parent Object Investment__c inv = (Investment__c)stdController.getRecord(); inv = [Select ID, Site__r.Address__c, Site__r.Postcode__c, Site__r.Town__c from Investment__c where id=:stdController.getRecord().Id limit 1]; SiteObj = inv.Site__r; //////
Ah, that's good, because it means it already knows who the parent is. You should therefore be able to display the parent info on the page regardless of the fact that the investment record is not yet in the database. Try this:
All Answers
What is the output of system.debug if you put it in here?
Hi
Output is:
USER_DEBUG|[26]|DEBUG|Investment__c:{Site__c=a0iA0000003dAva}
Thanks
Paul
Ah, that's good, because it means it already knows who the parent is. You should therefore be able to display the parent info on the page regardless of the fact that the investment record is not yet in the database. Try this:
Perfect - thanks a lot!