I am unable to fetch recortype in lightning component. Can anyone help me tell where is the issue

Code for component

<aura:component controller="EMTEventCreationWizardController" implements="lightning:actionOverride,force:lightningQuickAction,flexipage:availableForAllPageTypes,flexipage:availableForRecordHome,force:hasRecordId,lightning:isUrlAddressable" access="global" >
<aura:attribute name="recordId" type="Id"/>
<aura:attribute name="recordTypeId" type="String" />
<aura:attribute name="ObjectName" type="String" default="Events__c" access="global"/>
<aura:attribute name="eventRecordType" type="String"/> 

<aura:if isTrue="{!equals(v.eventRecordType,'Internal Event')}">
    <c:EMT_InternalEvent recordTypeId="{!v.recordTypeId}" eventRecordType="{!v.eventRecordType}" ObjectName="{!v.ObjectName}" recordId="{!v.recordId}"/>
  <aura:if isTrue="{!equals(v.eventRecordType,'External Event')}">
    <c:EMT_ExternalEvent recordTypeId="{!v.recordTypeId}" eventRecordType="{!v.eventRecordType}" ObjectName="{!v.ObjectName}" recordId="{!v.recordId}"/>

here is the code for my controller

 doInit : function(component, event, helper) {
    var recordTypeId = component.get("v.pageReference").state.recordTypeId
    console.log("recordType is "+recordTypeId);



Here is the code for helper

fetchRecordTypeName: function(component,event) {
    var action = component.get("c.getRecordTypeNameById");
        'objectName': component.get("v.ObjectName"),
        'strRecordTypeId': component.get('v.recordTypeId'),
    action.setCallback(this, function(response) {
        component.set("v.eventRecordType", response.getReturnValue());


Here is the code for apex controller

 public static String getRecordTypeNameById(String objectName, Id strRecordTypeId)
    return Schema.getGlobalDescribe().get(objectName).getDescribe().getRecordTypeInfosById().get(strRecordTypeId).getName();

Kindly let me know where i am getting it wrong

when i am trying to display recordtypeId to console from controller the value i get is undefined

  • 2
    Hi Smruti. It's hard to tell what is wrong without seeing any part of the code, could you provide some? My first assumtpion is that you do not preserve user provided values in any way. Easiest way for creating "wizards" is to create them in one parent component whith buttons next, back and preserve provided values in that parent component and just assume that back button in the browser clear everything (like in a lot outside Salesforce solutions) Feb 18, 2019 at 7:44
  • drive.google.com/drive/folders/… here is the link to my code.. can u please check and let me know where the problem is???? Feb 18, 2019 at 9:31
  • 4
    @SmrutiRanjanBiswal Please edit your question to include only the relevant portion of your code here. Based on your description, that would probably include the markup for a required field, the navigation handlers, and any custom validation code you have written.
    – David Reed
    Feb 18, 2019 at 12:27
  • If you have a completely different question, please open a new post rather than replacing the content of this one. This question is already closed, so no one can answer it.
    – David Reed
    Feb 20, 2019 at 13:54


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.