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;
}
})