I have a @remoteaction method that is a query on contacts with a subquery on a custom object.

When I get the response in javascript I'm using JSON.stringify() to examine the response and I'm not getting the subquery results:

[Log] [{"Name":"test guy","RecordTypeId":"012G0000000zOTZIA2","CreatedDate":1402533032000,"Id":"003J000000woxFNIAY"},{"Name":"test guy2","RecordTypeId":"012G0000000zOTZIA2","CreatedDate":1402582703000,"Id":"003J000000wpMGFIA2"}] (cordova, line 5180)

Has anyone been able to successfully receive the response from a subquery through a @remoteaction?


Yes, sub-queries are returned normally. Here's a simple example:


public with sharing class remote {
    @RemoteAction public static Account getAccounts() {
        return [SELECT Id, Name, (SELECT Id, Name FROM Contacts) FROM Account WHERE Name = 'Test' LIMIT 1];


<apex:page controller="remote">
    (function() {
        {!$RemoteAction.remote.getAccounts}(function(d,e) {
            var x = document.querySelector('#content'),
            t = document.createTextNode(JSON.stringify(d));
    <div id="content"></div>

Output in my org:

| improve this answer | |
  • yes, sorry I must have been staring at the screen too long, the records I was testing didn't have any sub records..duh – Phil B Jun 14 '14 at 12:51

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.