Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save salesforceBen/bb8af7a12f676d1b5f42b50ba995331b to your computer and use it in GitHub Desktop.
Save salesforceBen/bb8af7a12f676d1b5f42b50ba995331b to your computer and use it in GitHub Desktop.
Gist for SalesforceBen.com article about how to get dynamic picklist values without using the Salesforce UI API
// .cmp file:
<aura:component implements="flexipage:availableForRecordHome,force:hasRecordId,lightning:actionOverride,force:lightningquickActionWithoutHeader">
<aura:attribute name="RecordTypeId" type="String" access="public"/>
<aura:handler name="init" value="{!this}" action="{!c.doInit}" />
<lightning:recordEditForm aura:id="recordEditForm" recordId="{!v.RecordId}" recordTypeId="{!v.RecordTypeId}" objectApiName="Account" class="slds-p-top_small">
<span class="slds-hide slds-required" aura:id="required">*</span>
<lightning:inputField aura:id="picklist" fieldName="Industry" />
<lightning:inputField fieldName="RecordId" value="{!v.RecordId}" class="slds-hide" />
<lightning:inputField fieldName="RecordTypeId" value="{!v.RecordTypeId}" class="slds-hide" />
</lightning:recordEditForm>
<!--<lightning:recordEditForm aura:id="recordEditForm" recordId="{!v.RecordId}" recordTypeId="{!v.RecordTypeId}" objectApiName="Account" class="slds-p-top_small">
<span class="slds-hide slds-required" aura:id="required">*</span>
<lightning:inputField aura:id="picklist" fieldName="Ownership" />
<lightning:inputField fieldName="RecordId" value="{!v.RecordId}" class="slds-hide" />
<lightning:inputField fieldName="RecordTypeId" value="{!v.RecordTypeId}" class="slds-hide" />
</lightning:recordEditForm>-->
</aura:component>
// client side controller:
({
doInit : function(component, event, helper) {
console.log('the doInit was called');
var fullURL = window.location.href;
var recordTypeId = fullURL.substring(fullURL.indexOf("recordTypeId") + 13,fullURL.indexOf("recordTypeId") + 31);
console.log('the recordTypeId is: ' + recordTypeId);
if (recordTypeId != null) {
component.set("v.RecordTypeId", recordTypeId);
// console.log('the v.RecordTypeId is: ' + component.get("v.RecordTypeId"));
}
}
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment