function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Matthias GuentherMatthias Guenther 

In lightning how do I get to a components RecordType.Developername?

I have a controller that get a record:
@AuraEnabled
    public static Opportunity getOpp(Id oppId) {
        return [SELECT Id, Name, RecordType.Developername FROM Opportunity WHERE Id = :oppId];
    }

It works fine and gets the information, but I cannot figure out how to get to RecordType.Developername in lightning.
var o = response.getReturnValue();
console.log('Current o: ' + o);
console.log('Current o.Id: ' + o.Id);
console.log('Current o.RecordType.Developername: ' + o.RecordType.Developername);
Current o: [object Object]
Current o.Id: 0060L00000VyqTYQAZ
Current o.RecordType.Developername: undefined

I could get just the recordtype Id and make another call to get the developer name, but that seems to be an avoidable step. I did not find anything about this in the documentation or searching.
Best Answer chosen by Matthias Guenther
Matthias GuentherMatthias Guenther
need to use o.RecordType.DeveloperName  javascript is case sensitive....

 

All Answers

Matthias GuentherMatthias Guenther
This is the log for console.log( o );
 
{Id: "006E000000EY2SGIA1", Name: "Tab Score Test", RecordTypeId: "012E00000005QHKIA2", RecordType: {…}}
Id:"006E000000EY2SGIA1"
Name:"Tab Score Test"
RecordType:DeveloperName:"Funding_Opportunity"
Id:"012E00000005QHKIA2"
__proto__:Object
RecordTypeId:"012E00000005QHKIA2"
__proto__:Object
The info is coming back, question is how do I access it?
 
Matthias GuentherMatthias Guenther
need to use o.RecordType.DeveloperName  javascript is case sensitive....

 
This was selected as the best answer