function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Timothy Wong 2Timothy Wong 2 

lightning set default value for dependent picklist

Hi
I am having trouble to set the default value for the dependent picklist in lightning by using the createRecordEvent + defaultFieldValues. I have a custom button to create new opportunity and it will grab data from account and pre-fill in opportunity. Everything works except the dependent picklist and seem like the field is lock in lightning and I can't figure a way to pre-select the value for the user. And the dependent picklist is a required field so the user has to fill in something so workflow may not be ideal for this case. Does anyone has any ideas? Please help!!

            createRecordEvent.setParams({
                "entityApiName": "Opportunity",
                "recordTypeId":rtDet.id,
                "defaultFieldValues": {
                    'AccountId' : Account.Id ,
                    'CurrencyIsoCode' : Account.CurrencyIsoCode,
                    'Type' : OpportunityType,
                    'City__c' : Account.City__c,
                    'Region__c' : Account.Region_n__c
                }
            });
Raj VakatiRaj Vakati
createRecordEvent.setParams({
                "entityApiName": "Opportunity",
                "recordTypeId":rtDet.id,
                "defaultFieldValues": {
                    'AccountId' : Account.Id ,
                    'CurrencyIsoCode' : Account.CurrencyIsoCode,
                    'Type' : OpportunityType,
                    'City__c' : 'CITY_NAME',
                    'Region__c' : 'REGION_NAME'
					}
            });

OR
 
<aura:attribute name="city" type="String" defualt="cityname" />
		<aura:attribute name="region" type="String" defualt="regionname" />
		
		
			
			 createRecordEvent.setParams({
                "entityApiName": "Opportunity",
                "recordTypeId":rtDet.id,
                "defaultFieldValues": {
                    'AccountId' : Account.Id ,
                    'CurrencyIsoCode' : Account.CurrencyIsoCode,
                    'Type' : OpportunityType,
                    'City__c' :{!v.city},
                    'Region__c' : {!v.region}
                }
            });

Timothy Wong 2Timothy Wong 2
Raj V
I didn't make myself clear. I can't pre-fill "any" dependance picklist with defaultFieldValues. Nothing to do with the code, not even hardcoded with "'Region__c' : 'North America'"