You need to sign in to do that
Don't have an account?
louisa barrett 7
didn't understand relationship Project_Checklist__r in FROM part of query
Hi,
I have two custom objects Project_sheet_2 and Project_checklist, they both have a look up to Opportunity.
On the Poject_sheet_2 VF page I would like to display all the associated Project_checklist objects and vice versa.
I'm holding the Opporutnity ID in a variable(projSheet.PS2_Opportunity__c) as I'm also displaying the Opportunity Product Items.
I have the following code on my Project Sheet controller, which I thought should work.....
public List<Project_Checklist__c> getOppChecklists(){
List<Project_Checklist__c> lstChecklists = [SELECT Name,(SELECT name FROM Poject_checklist__R) FROM Opportunity WHERE ID =:projSheet.PS2_Opportunity__c];
return lstChecklists;
}
Many thanks
I have two custom objects Project_sheet_2 and Project_checklist, they both have a look up to Opportunity.
On the Poject_sheet_2 VF page I would like to display all the associated Project_checklist objects and vice versa.
I'm holding the Opporutnity ID in a variable(projSheet.PS2_Opportunity__c) as I'm also displaying the Opportunity Product Items.
I have the following code on my Project Sheet controller, which I thought should work.....
public List<Project_Checklist__c> getOppChecklists(){
List<Project_Checklist__c> lstChecklists = [SELECT Name,(SELECT name FROM Poject_checklist__R) FROM Opportunity WHERE ID =:projSheet.PS2_Opportunity__c];
return lstChecklists;
}
Many thanks
So to return the last name of all Parent, and for each Parent returned, the last name of the parent's child we will use this query.
Here in your case Project_Checklist__r represents the relationship name.
It will return Name of all the oppurtunity and for each oppurtunity returned, the name of realted Project_checklist.
For more detail refer this link : https://developer.salesforce.com/docs/atlas.en-us.soql_sosl.meta/soql_sosl/sforce_api_calls_soql_relationships_and_custom_objects.htm
Hope you got the solution.
Mark this answer as Best Answer if this help you.
All Answers
So to return the last name of all Parent, and for each Parent returned, the last name of the parent's child we will use this query.
Here in your case Project_Checklist__r represents the relationship name.
It will return Name of all the oppurtunity and for each oppurtunity returned, the name of realted Project_checklist.
For more detail refer this link : https://developer.salesforce.com/docs/atlas.en-us.soql_sosl.meta/soql_sosl/sforce_api_calls_soql_relationships_and_custom_objects.htm
Hope you got the solution.
Mark this answer as Best Answer if this help you.