0

I have a custom object called Employee and another object called Device

Device is a lookup relationship to Employee object

I'm trying to pull the Device RecordType.Name something like this:

SELECT id, Name, device__r.RecordType.Name from Employee__c

in the Developer Console I see its pulling the data but the column is displaying like this [Object Object] What do I need to show the actual data?

5
  • Could you please reference us here the Javascript code you're using to show the query result? (I suspect you're using JS from that [Object Object])
    – MLucci
    Aug 13, 2015 at 17:04
  • no, i am not using javascript, as i said i run that query in developer console
    – Nick
    Aug 13, 2015 at 17:04
  • Where is that [Object Object] showing up in the Dev Console specifically? In query results from the Query Editor tab or from Anonymous Apex?
    – MLucci
    Aug 13, 2015 at 17:06
  • in the query editor tab thats correct
    – Nick
    Aug 13, 2015 at 17:07
  • I just discovered this behavior. Another reason more for me not to use that tool!
    – MLucci
    Aug 13, 2015 at 17:11

2 Answers 2

2

When performing this from the Dev Console Query editor, it will not show the actual value it will show as you have posted in your answer.

However, if you run execute anonymous it will display as you wish:

Employee__c[] emp = [SELECT id, Name, device__r.RecordType.Name from Employee__c];
if(!emp.isEmpty())
    system.debug(rmp[0].Device__r.RecordType.Name);
else
    system.debug('No results returned');

See related answer here: Child-to-Parent Query - [object Object] is the result

-2

Try this using recordtype.developername

// Map is custom_object__1 to developer name of custom_object__2 record type
Map<Id, String> m = new Map<Id, String>();
for (custom_object__2 c2 : [
        select custom_object__1, RecordType.DeveloperName
        from custom_object__2
        where custom_object__1 in :Trigger.newMap.keySet()
        ]) {
    m.put(c2.custom_object__1, c2.RecordType.DeveloperName);
}

for (custom_object__1 c1 : Trigger.new) {
    String developerName = m.get(c1.Id);
    if (developerName == 'xyz') {
        ...
    }
}
}
1
  • huh????????????????????
    – Nick
    Aug 13, 2015 at 17:21

Not the answer you're looking for? Browse other questions tagged .