Last active
February 2, 2020 13:27
-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// .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