custom dependent picklist

Custom Dependent Picklist Field With lightning:select In Lightning Component

Lightning Component

Hey guys, today in this post we are going to create a new updated version of Custom Dependent Picklist fields using ‘lightning:select‘ base component in salesforce.

Custom dependent picklist salesforce sfdcmonkey

Prerequisites : basic understanding of Lightning Component & apex Programming
Step  0 : Setup Picklist field dependency

In this post , first we have create 2 custom picklist fields on salesforce  standard Contact object

Country__c &  City__c

then set field dependency. here country is the controller field  and city is the dependent field.

Custom dependent picklist salesforce sfdcmonkey

Step  1 : Create apex controller
[dependentPicklist_UpdateCtrl.apxc]

  • you don’t need to change anything in above apex classes.
Step  2 : Create Lightning Component
DependentPicklist.cmp

DependentPicklistController.js

Check also :  Custom Multi-Select Picklist In Lightning Component With Select2 jQuery Plugin
DependentPicklistHelper.js

 

  • check above code comments.
  • You just need to change the object API Name/Type on line number 15.[DependentPicklist.cmp].
  • And change dependent field and controller field API Names on line number 16 – 17.[DependentPicklist.cmp].

TestApp.app

Custom dependent picklist salesforce sfdcmonkey
Result

Like our facebook page for new post updates.? & Don’t forget to bookmark this site for your future reference.

 Let us know if it helps you 🙂

people also check : How to use SVG in Salesforce Lightning Component ?

 

(Visited 2,100 times, 64 visits today)

2 comments

  • Hi,

    Thanks a lot for this component. Its really helpful!

    I need to store the values of the above component details along with another component values by clicking on save button. May I know how this can be achieved please!

    Thanks in advance:)

Leave a Reply