15

I'm trying to perform the following multilevel relationship query.

SELECT ID, SystemModstamp, Product__r.Catalog__r.Active__c 
FROM Journal__c     
WHERE SystemModstamp > 2013-10-02T00:00:00.000+0000 
AND SystemModstamp < 2013-10-05T00:00:00.000+0000 

In the Product__r.Catalog__r.Active__c column I'm getting a value of [object Object] for every single record. I can substitute any field name from the Catalog__c object and get the same response. Does anyone know why this is happening or how to get the field's actual value?

  • No problem Danny :) What field type is the Active__c? – Sergej Utko Oct 9 '13 at 14:50
  • Active__c is a checkbox. I get the same result, however, using the Name field or RecordType field or any other field I put in there from the Catalog__c object. – dannymorty Oct 9 '13 at 14:56
  • Where is the query result used? – Sergej Utko Oct 9 '13 at 14:59
  • 1
    I'm performing the query in the Dev Console. It's part of a larger question of what caused 16000 Journal__c records to have their SysModstamp values all update last Friday morning. – dannymorty Oct 9 '13 at 15:00
18

I believe this is currently a limitation or bug of the dev console. Trying to flatten a javascript object to a string returns the literal "[object Object]" you're seeing here, but would work for non-cross-object fields.

I've seen it before myself, but I've never had the time to open a support case about it, if you're able to it's certainly worth reporting it as an issue with the dev console.

In the meantime the query is perfectly valid and if you run anonymous apex like

System.debug(JSON.serialize([SELECT ID, SystemModstamp, Product__r.Catalog__r.Active__c 
FROM Journal__c     
WHERE SystemModstamp > 2013-10-02T00:00:00.000+0000 
AND SystemModstamp < 2013-10-05T00:00:00.000+0000]));

you should get a JSON representation of the query results in the debug log that you can work with in your text editor of choice (although you might want to run it through http://jsbeautifier.org/ for readability). Otherwise consider alternative tools like force.com workbench of SOQLXplorer. Which can handle displaying cross-object query results.

|improve this answer|||||
  • 3
    I'd call it a limitation, I suppose. Not really a bug, or you'd get some silly error message, right? That aside, you can probably flatten the query as well (the point of using dev console query would be to possibly edit/view the records directly). – sfdcfox Oct 9 '13 at 15:17
  • @sfdcfox I wouldn't really expect an error - they're probably building the columns from all the properties of the result object, and if you do that without recursing into any fields that are objects you end up with [object Object] by calling toString() on the relationship field when trying to render the row. Javascript is weird. – ca_peterson Oct 9 '13 at 15:24
  • 3
    Force.com workbench did the trick for me. I had to go into settings and check the box for "Allow SOQL Parent Relationship Queries", which it told me to do, but after that it worked a charm. – dannymorty Oct 9 '13 at 15:52
  • 5
    Yes, known "limitation" with the dev console just like subqueries show the raw json, along with others. We have stories to improve the query view in the dev console but they are not high priority. The more feedback like this and more query editor traffic will help us prioritize in the future. – Thomas Oct 9 '13 at 16:21
  • 2
    For those who don't know @Thomas is one of the developers behind the dev console. Thanks fro stopping by! – ca_peterson Oct 9 '13 at 16:51
2

Can you try Anonymous Apex and try to print out the list in Debug Logs?

List< Journal__c> journeyList = [SELECT ID, SystemModstamp,Product__r.Catalog__r.Active__c 
FROM Journal__c LIMIT 10];
System.debug(journeyList);
|improve this answer|||||
  • 1
    I've tried this and got a result with all field valued just ok. – Sergej Utko Oct 9 '13 at 15:22

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.