0

I have an Aura component which wraps a couple of LWCs, which overrides 'New' Button of the listview. (From: Getting RecordTypeId selected from 'Record Type Selection' Page, in a lightning component that overrides create screen)

I am wondering if there is any possible way to get the RecordType's Name by its Id, WITHOUT running a SOQL query.

I figured out that I can query it on the backside but it'd be the last thing that I'd want to do.

doInit: function(component) {
    var recordTypeId = component.get("v.pageReference").state.recordTypeId;
    component.set("v.recordTypeId", recordTypeId);
}
// then I pass recordTypeId to LWC which simply displays it.

1 Answer 1

2

If you're already wrapping a couple of LWCs in your Aura Component, then you could create a new LWC to do this using a variation of the example used in the documentation to explain usage of the getRecordInfo wire method.

In that example, they're looking to return the Record Type Id based on the Name, but we can alter it slightly to return the Name based on the Id.

    @wire(getObjectInfo, { objectApiName: OBJECT_NAME })
    objectInfo;

    get recordTypeName() {
        // Returns a map of record type Ids 
        const rtis = this.objectInfo.data.recordTypeInfos;
        return rtis.get(this.recordTypeId).name;
    }
1
  • Thanks, it worked :) Commented Dec 22, 2022 at 9:01

You must log in to answer this question.

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