getting picklist values dynamically by w3web.net

How to fetch picklist values from apex controller in lightning component

Hey guys, In this post we are going to learn about how to retrieve Picklist values from Apex controller in Lightning Component.

Files we used in this post example:-

statusApp.app Lightning Application It is used for call the component to preview on browser.
statusCmp.cmp Lightning Component It is used for create a picklist select option field.
statusCmpController.js JavaScript Controller File It is used for communicate to server side apex method and fetch the picklist value from init fuction.
statusCmpHelper.js JavaScript Helper File Helper function call in to javascript init function.
pickListController.apxc Apex Class Controller It is used for retrieve picklist values from database.

Custom Object:- Course__c

Custom Object Picklist Fields:-

Status__c

Picklist Value:-

Active,

Inactive

 

Custom Object and their fields

We retrieve picklist values from custom field and display on the dropdown.

 

Final Output

fetching picklist values dynamically in lightning by w3web.net

Other related post that would you like to learn in lightning component.

Step 1:- Create Lightning Application : statusApp.app

From Developer Console >> File >> New >> Lightning Application

statusApp.app [Component Application File]

Step 2:- Create Lightning Component : statusCmp.cmp

From Developer Console >> File >> New >> Lightning Component

statusCmp.cmp [Lightning Component]

Step 3:- Create Lightning Component : statusCmpController.js

From Developer Console >> File >> New >> Lightning Component >> JavaScript Controller

statusCmpController.js [JavaScript Controller]

Step 4:- Create Lightning Component : statusCmpHelper.js

From Developer Console >> File >> New >> Lightning Component >> JavaScript Helper

statusCmpHelper.js [JavaScript Helper]

Step 5:- Create Lightning Application : pickListController.apxc

From Developer Console >> File >> New >> Apex Class

pickListController.apxc [Apex Class Controller]

Further post that would you like to learn in lightning component.

Hi, This is Vijay behind the admin and founder of w3web.net. I am a senior software developer and working in MNC company from more than 8 years. I am great fan of technology, configuration, customization & development. Apart of this, I love to write about Blogging in spare time, Working on Mobile & Web application development, Salesforce lightning, Salesforce LWC and Salesforce Integration development in full time.

10 thoughts on “How to fetch picklist values from apex controller in lightning component”

Leave a Comment