You need to sign in to do that
Don't have an account?
Jay Kanchana
Retrieving Parent Field in SOQL and Displaying on Visual Force page
Hello!
Currently we display a pageblocktable that lists child records on a visual force page. We would like to display the parent name as well for each record.
for example we have
Parent__c
Child__c
Lookup__c
Current Query is something like
[SELECT id, Deliverable__c,
Description__c, Parent__c
FROM Child__c
WHERE Lookup__c=:Lookup_Id
];
We want to add the Parent__c.Name to the SOQL.
FollowingSOQL works, butthe visual force page displays the error that the data is being displayed without retrieving. Visualforce page code is something like - {!c.Parent__r.Name} .
[SELECT id, Deliverable__c,
Description__c, Parent__r.Name
FROM Child__c
WHERE Lookup__c=:Lookup_Id
];
This gives a soql error that the relationship does not exist.
[SELECT id, Deliverable__c,
Description__c, (select Name from Parent__r)
FROM Child__c
WHERE Lookup__c=:Lookup_Id
];
Wither my SOQL is wrong or may be there is a different way to display the parent name in the visual force page?
Thank you!
Jay
Currently we display a pageblocktable that lists child records on a visual force page. We would like to display the parent name as well for each record.
for example we have
Parent__c
Child__c
Lookup__c
Current Query is something like
[SELECT id, Deliverable__c,
Description__c, Parent__c
FROM Child__c
WHERE Lookup__c=:Lookup_Id
];
We want to add the Parent__c.Name to the SOQL.
FollowingSOQL works, butthe visual force page displays the error that the data is being displayed without retrieving. Visualforce page code is something like - {!c.Parent__r.Name} .
[SELECT id, Deliverable__c,
Description__c, Parent__r.Name
FROM Child__c
WHERE Lookup__c=:Lookup_Id
];
This gives a soql error that the relationship does not exist.
[SELECT id, Deliverable__c,
Description__c, (select Name from Parent__r)
FROM Child__c
WHERE Lookup__c=:Lookup_Id
];
Wither my SOQL is wrong or may be there is a different way to display the parent name in the visual force page?
Thank you!
Jay
Description__c, Parent__r.Name
FROM Child__c
WHERE Lookup__c=:Lookup_Id' should work. other query is wrong..you cant get the parent values in the sub query..