You need to sign in to do that
Don't have an account?

Parent to Child relationship query question
I have a parent to child relationship query question. Here's a snippet of my code:
Code:
var queryString = "SELECT FirstName, LastName, " + "(SELECT Subject, Id FROM Events WHERE Subject = 'x') " + "FROM Contact " + "WHERE Organization__c = '{!Contact.Organization__c}' " + "AND ZoneR__c = 'x' " + "AND Sub_ZoneR__c = 'x' " + "AND Primary_Cost_Center__c = 'xxxx' " + "AND ((Production__c = 'A') OR (Id = '{!Contact.Id}') OR " + "(Production__c = 'B') OR (Production__c = 'C') OR " + "(Production__c = 'C')) " + "LIMIT 100"; var queryResult = sforce.connection.query(queryString); results = queryResult.getArray ("records");
I'm trying to gather events information from a list of contacts. In my query, I'm trying to get a list of contacts that match a certain criteria and for each contact, I get the events' id and subject if they have any. Question is: how can I store the results that I get back from the parent-child relationship into a variable? In my example, if I wanted to get the contact's first name from the query result, I could assign a variable to results.FirstName. But I'm not sure how to accomplish the same for the results I get from the Parent to Child relationship (the events' info that I get back).
Thanks in advance.
Message Edited by HL-Dev on 06-13-2008 01:27 PM
Try incorporating something like this into your code and see if it helps.
I will give this a shot. Thanks!
If you are not familiar with Visualforce follow these steps in your Developer Edition or Sandbox account:
- Go to your user record under setup and click edit
- Check the "Development Mode" preference (if you don't see it then you are probably not an administrator)
- Save your user record
- In your address bar type /apex/contactsWithEvents after ...salesforce.com
- Hit enter
- Click the link that says "Create Page contactsWithEvents"
- Click the "Page Editor" tab in the footer
- Paste in the page markup above
- Click the save button in the toolbar
- When you are prompted that the controller ContactsWithEventsCon does not exist, click the link to create it
- You'll then be prompted to create a "getContacts" method, don't click on that. Instead click on the controller tab.
- Replace the default controller code with that from above
- Click the save button in the toolbar.
- Viola!
These and other getting started details can be found in the visualforce developer guide[edit] thought you might be interested in the output of the above Visualforce page/controller - see screenshot below my signature
Regards,
Message Edited by mtbclimber on 06-21-2008 11:15 AM