I'm using Visualforce Remoting to get information about a Contact. I want to get a specific Attachment related to the Contact at the same time (which is linked through ParentId).
When I return the Contact, the result does not seem to include information about the child objects.
My Contacts.page
Visualforce.remoting.Manager.invokeAction('{!$RemoteAction.MyContactsController.getContact}',
contactId,
function(result, event){
console.log(result);
}
);
RemoteAction:
@RemoteAction
global static Contact getContact(Id contactId){
Contact selContact = [SELECT Id, (Select Id from Attachments where ParentId = :contactId and Name = 'Contact Picture'), Name, FirstName, LastName FROM Contact WHERE Id=:contactId limit 1];
return selContact;
}
console.log returns:
result: Object
FirstName: "John" Id: "003U000000s2RmEIAU" LastName: "Smith" Name: "John Smith"
and there is no Attachments array. I know I could do it with another RemoteAction, or by using a Wrapper Class, but I thought this would work.