Skip to main content
added 117 characters in body
Source Link
Reshma
  • 4.1k
  • 7
  • 29
  • 43

Component: <aura:attribute name="recordTypeIdVar" type="String"/> <lightning:recordEditForm aura:id="recordEditForm" objectApiName="Case" recordId="{!v.recordId}" recordTypeId="{!v.recordTypeIdVar}" onload="{!c.showRequiredFields}" onsuccess="{!c.handleSuccess}"> <h3 class="slds-section-title--divider"> <p>RecordType: {!v.recordTypeIdVar}</p> <lightning:outputField fieldName="RecordTypeId"/> </h3> blabla code here.. and close the component

<aura:attribute name="recordTypeIdVar" type="String"/>
    <lightning:recordEditForm aura:id="recordEditForm" 
                              objectApiName="Case"
                              recordId="{!v.recordId}" 
                              recordTypeId="{!v.recordTypeIdVar}"
                              onload="{!c.showRequiredFields}"
                              onsuccess="{!c.handleSuccess}">
                <h3 class="slds-section-title--divider">
                    <p>RecordType: {!v.recordTypeIdVar}</p>
                    <lightning:outputField fieldName="RecordTypeId"/> 
                </h3>

blabla code here.. and close the component

Controller: showRequiredFields: function(component, event, helper){ // To get the record type from URL as it is not happening by default. var recordTypeIdParam = helper.getJsonFromUrl().recordTypeId; //alert("recordTypeId= " + recordTypeIdParam); component.set("v.recordTypeIdVar", recordTypeIdParam); },

showRequiredFields: function(component, event, helper){
       // To get the record type from URL as it is not happening by default.
        var recordTypeIdParam = helper.getJsonFromUrl().recordTypeId;
         //alert("recordTypeId= " + recordTypeIdParam);
        component.set("v.recordTypeIdVar", recordTypeIdParam);
    },

Helper: ({ getJsonFromUrl : function () { var query = location.search.substr(1); var result = {}; query.split("&").forEach(function(part) { var item = part.split("="); result[item[0]] = decodeURIComponent(item[1]); }); return result; } })

({
 getJsonFromUrl : function () {
        var query = location.search.substr(1);
        var result = {};
        query.split("&").forEach(function(part) {
            var item = part.split("=");
            result[item[0]] = decodeURIComponent(item[1]);
        });
        return result;
    }
})

Component: <aura:attribute name="recordTypeIdVar" type="String"/> <lightning:recordEditForm aura:id="recordEditForm" objectApiName="Case" recordId="{!v.recordId}" recordTypeId="{!v.recordTypeIdVar}" onload="{!c.showRequiredFields}" onsuccess="{!c.handleSuccess}"> <h3 class="slds-section-title--divider"> <p>RecordType: {!v.recordTypeIdVar}</p> <lightning:outputField fieldName="RecordTypeId"/> </h3> blabla code here.. and close the component

Controller: showRequiredFields: function(component, event, helper){ // To get the record type from URL as it is not happening by default. var recordTypeIdParam = helper.getJsonFromUrl().recordTypeId; //alert("recordTypeId= " + recordTypeIdParam); component.set("v.recordTypeIdVar", recordTypeIdParam); },

Helper: ({ getJsonFromUrl : function () { var query = location.search.substr(1); var result = {}; query.split("&").forEach(function(part) { var item = part.split("="); result[item[0]] = decodeURIComponent(item[1]); }); return result; } })

Component:

<aura:attribute name="recordTypeIdVar" type="String"/>
    <lightning:recordEditForm aura:id="recordEditForm" 
                              objectApiName="Case"
                              recordId="{!v.recordId}" 
                              recordTypeId="{!v.recordTypeIdVar}"
                              onload="{!c.showRequiredFields}"
                              onsuccess="{!c.handleSuccess}">
                <h3 class="slds-section-title--divider">
                    <p>RecordType: {!v.recordTypeIdVar}</p>
                    <lightning:outputField fieldName="RecordTypeId"/> 
                </h3>

blabla code here.. and close the component

Controller:

showRequiredFields: function(component, event, helper){
       // To get the record type from URL as it is not happening by default.
        var recordTypeIdParam = helper.getJsonFromUrl().recordTypeId;
         //alert("recordTypeId= " + recordTypeIdParam);
        component.set("v.recordTypeIdVar", recordTypeIdParam);
    },

Helper:

({
 getJsonFromUrl : function () {
        var query = location.search.substr(1);
        var result = {};
        query.split("&").forEach(function(part) {
            var item = part.split("=");
            result[item[0]] = decodeURIComponent(item[1]);
        });
        return result;
    }
})
Source Link

I have faced same issue. I have found very simple solution. I may be late in answering but it can help someone in need.

Component: <aura:attribute name="recordTypeIdVar" type="String"/> <lightning:recordEditForm aura:id="recordEditForm" objectApiName="Case" recordId="{!v.recordId}" recordTypeId="{!v.recordTypeIdVar}" onload="{!c.showRequiredFields}" onsuccess="{!c.handleSuccess}"> <h3 class="slds-section-title--divider"> <p>RecordType: {!v.recordTypeIdVar}</p> <lightning:outputField fieldName="RecordTypeId"/> </h3> blabla code here.. and close the component

Controller: showRequiredFields: function(component, event, helper){ // To get the record type from URL as it is not happening by default. var recordTypeIdParam = helper.getJsonFromUrl().recordTypeId; //alert("recordTypeId= " + recordTypeIdParam); component.set("v.recordTypeIdVar", recordTypeIdParam); },

Helper: ({ getJsonFromUrl : function () { var query = location.search.substr(1); var result = {}; query.split("&").forEach(function(part) { var item = part.split("="); result[item[0]] = decodeURIComponent(item[1]); }); return result; } })