1

I am quite new to Salesforce so I am very confused about this. I have a query:

SELECT Contact.Name, Contact.Owner.IsActive FROM Contact

When I run this query in Workbench, I got correct results:

1 Jon Snow true

2 llastName... true

3 llastName... true

4 Ion Hellion true

But when I run this query in web Developer Console or in Eclipse's Execute Anonymous, I got incorrect results:

(Contact:{Name=Jon Snow, OwnerId=0057E0000012qtHQAQ, Id=0037E00000CHsPvQAL}, Contact:{Name=llastName..., OwnerId=0057E000000jEVuQAM, Id=0037E00000Cb0fKQAR}, Contact:{Name=llastName..., OwnerId=0057E000000jEVuQAM, Id=0037E00000Cb0UHQAZ}, Contact:{Name=Ion Hellion, OwnerId=0057E000000jEVuQAM, Id=0037E00000CazxDQAR}, ...)

To be more precise -- in the second case I got only OwnerId despite how many or which fields of the Owner I actually query. E.g. I coud query SELECT Contact.Name, Owner.Name, Owner.Id, Owner.MagicalUnicorn FROM Contact and result would be same.

Thanks in regards for clarification.

1
  • 1
    These tools implement the presentation of data from related objects differently. In Apex code you will need to explicitly reference c.Owner.IsActive.
    – Keith C
    Feb 24 '17 at 8:42
0

In execute anonymous you are running the following script:

system.debug([SELECT Contact.Name, Contact.Owner.IsActive FROM Contact]);

This query returns a list of Contact records, where the Owner information is in separate objects that can be reference from the returned contacts.

If you run the following script in execute anonymous, the results should better mirror what you are seeing in workbench.

list<Contact> clist = [SELECT Contact.Name, Contact.Owner.IsActive FROM Contact];
for (Contact c : clist) system.debug(c.Name + ' ' + c.Owner.IsActive);
2
  • thanks, it is bit difficult to change my point of view but now I can see :)
    – Qerts
    Feb 24 '17 at 8:58
  • no problem. What you are seeing in execute anonymous is more of a raw response, but ultimately, the data is all there.
    – martin
    Feb 24 '17 at 9:01

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.