Child-to-Parent Query – [object Object] is the result

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?

Answer

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.

Attribution
Source : Link , Question Author : dannymorty , Answer Author : ca_peterson

Leave a Comment