How to display selected multiple picklist value move left/right from one box to another dual-listbox of dropdown picklist based on button icon to reordered as up/down of selected picklist option uses of ‘lightning-dual-listbox’ element in LWC Salesforce (Lightning Web Component) | Create a pair of listboxes that enables multiple options to selected and reordered of picklist option value in Salesforce LWC

4,865 views

Hey guys, today in this post we are going to learn about How to display selected multiple picklist value move left/right from one box to another dual-listbox of dropdown picklist based on button icon to reordered as up/down of selected picklist option uses of ‘lightning-dual-listbox’ element in LWC Salesforce (Lightning Web Component).

A lightning-dual-listbox component represents two side-by-side listboxes. Select one or more options in the list on the left. Move selected options to the list on the right. The order of the selected options is maintained and you can reorder options.

A dual listbox with options. Use the onchange event handler to capture what’s selected.

Note:: – You will get an email, so put correct email and mobile number and BEGIN YOUR JOURNEY from Today!

 

Here’s an example that creates a simple dual listbox with 6 options. To know more details about lightning-dual-listbox, Click Here..

 

Files we used to create lightning-dual-listbox to select multiple options in Salesforce LWC →

lwcMultipleOptions.html LWc HTML File Template HTML file to create lightning-dual-listbox to select multiple options in Salesforce Lightning Web Component (LWC)
lwcMultipleOptions.js LWC JavaScript File It’s javascript actions functions to control multiple select options in Salesforce LWC
lwcMultipleOptions.js-meta.xml XML Meta File It is used to where this lightning web component file you want to display as lightning__AppPage, lightning__RecordPage, lightning__HomePage.
lwcMultipleOptionsApp.app Lightning Application It is used for call the component and preview on browser.

 

 

Final Output →

control multiple select options in lwc -- w3web.net
 

 

You can download file directly from github by Click Here.

 
 

 

You can download file directly from github by Click Here.

 

 

Other related post that would you like to learn in Salesforce

Note:: – You will get an email, so put correct email and mobile number and BEGIN YOUR JOURNEY from Today!
 
 

 

Create Lightning Web Component HTML →

Step 1:- Create Lightning Web Component : lwcMultipleOptions.html

SFDX:Lightning Web Component >> New >> lwcMultipleOptions.html

lwcMultipleOptions.html [Lightning Web Component HTML]

  1.   <template>
  2.     <div class="slds-p-around_medium">
  3.         <h3 class="slds-text-heading_medium"><lightning-icon icon-name="custom:custom89" size="small"></lightning-icon> <strong style="color:#270086; font-size:13px; margin-right:5px;"> Create multiple select options in Salesforce Lightning Web Component (LWC) </strong></h3>
  4.             <br/><br/>
  5.  
  6.             <lightning-dual-listbox name="languages"
  7.                             label="Select Languages"
  8.                             source-label="Available"
  9.                             selected-label="Selected"
  10.                             field-level-help="Select your preferred languages"
  11.                             options={options}
  12.                             onchange={handleChange}></lightning-dual-listbox>
  13.     <div class="slds-box" >
  14.         <p>Selected values are: {selected}</p>
  15.     </div>
  16.  
  17.  
  18.     <br/><br/>
  19.         <!--Start RelatedTopics Section-->
  20. <div style="border:1px #ddd solid; padding:10px; background:#eee; margin:40px 0;">
  21.  
  22.             <p data-aura-rendered-by="435:0"><img src="https://www.w3web.net/wp-content/uploads/2021/05/thumbsUpLike.png" width="25" height="25" style="vertical-align:top; margin-right:10px;" data-aura-rendered-by="436:0"><strong data-aura-rendered-by="437:0"><span style="font-size:16px; font-style:italic; display:inline-block; margin-right:5px;">Don't forget to check out:-</span><a href="https://www.w3web.net/" target="_blank" rel="noopener noreferrer" style="text-decoration:none;" data-aura-rendered-by="440:0">An easy way to learn step-by-step online free Salesforce tutorial, To know more Click  <span style="color:#ff8000; font-size:18px;" data-aura-rendered-by="442:0">Here..</span></a></strong></p>
  23.  
  24.             <br/><br/>
  25.             <p data-aura-rendered-by="435:0"><img src="https://www.w3web.net/wp-content/uploads/2021/07/tickMarkIcon.png" width="25" height="25" style="vertical-align:top; margin-right:10px;" data-aura-rendered-by="436:0"><strong data-aura-rendered-by="437:0"><span style="font-size:17px; font-style:italic; display:inline-block; margin-right:5px; color:rgb(255 128 0);">You May Also Like →</span> </strong></p>
  26.             <div style="display:block; overflow:hidden;"> 
  27.                 <div style="width: 50%; float:left; display:inline-block">
  28.                     <ul style="list-style-type: square; font-size: 16px; margin: 0 0 0 54px; padding: 0;"> 
  29.                         <li><a href="https://www.w3web.net/lwc-get-set-lightning-checkbox-value/" target="_blank" rel="noopener noreferrer">How to get selected checkbox value in lwc</a></li>
  30.                         <li><a href="https://www.w3web.net/display-account-related-contacts-in-lwc/" target="_blank" rel="noopener noreferrer">how to display account related contacts based on AccountId in lwc</a></li>
  31.                         <li><a href="https://www.w3web.net/create-lightning-datatable-row-actions-in-lwc/" target="_blank" rel="noopener noreferrer">how to create lightning datatable row actions in lwc</a></li>
  32.                         <li><a href="https://www.w3web.net/if-and-else-condition-in-lwc/" target="_blank" rel="noopener noreferrer">how to use if and else condition in lwc</a></li>
  33.                         <li><a href="https://www.w3web.net/get-selected-radio-button-value-and-checked-default-in-lwc/" target="_blank" rel="noopener noreferrer">how to display selected radio button value in lwc</a></li>
  34.                     </ul>
  35.             </div>
  36.  
  37.             <div style="width: 50%; float:left; display:inline-block">
  38.                     <ul style="list-style-type: square; font-size: 16px; margin: 0 0 0 54px; padding: 0;"> 
  39.                         <li><a href="https://www.w3web.net/display-account-related-contacts-lwc/" target="_blank" rel="noopener noreferrer">display account related contacts based on account name in lwc</a></li>
  40.                         <li><a href="https://www.w3web.net/create-lightning-datatable-row-actions-in-lwc/" target="_blank" rel="noopener noreferrer">how to insert a record of account Using apex class in LWC</a></li>
  41.                         <li><a href="https://www.w3web.net/fetch-picklist-values-dynamic-in-lwc/" target="_blank" rel="noopener noreferrer">how to get picklist values dynamically in lwc</a></li>
  42.                         <li><a href="https://www.w3web.net/edit-save-and-remove-rows-dynamically-in-lightning-component/" target="_blank" rel="noopener noreferrer">how to edit/save row dynamically in lightning component</a></li>
  43.                         <li><a href="https://www.w3web.net/tree-grid-dynamic-expand-collapse-in-lwc/" target="_blank" rel="noopener noreferrer">how to create tree grid with expanded/collapsed section for the entire row in LWC</a></li>
  44.                     </ul>
  45.                 </div>
  46.                <div style="clear:both;"></div> 
  47.                <br/>
  48.                 <div class="youtubeIcon">
  49.                     <a href="https://www.youtube.com/channel/UCW62gTen2zniILj9xE6LmOg" target="_blank" rel="noopener noreferrer"><img src="https://www.w3web.net/wp-content/uploads/2021/11/youtubeIcon.png" width="25" height="25" style="vertical-align:top; margin-right:10px;"/> <strong>TechW3web:-</strong> To know more, Use this <span style="color: #ff8000; font-weight: bold;">Link</span> </a>
  50.                 </div>
  51.     </div>
  52.  
  53. </div>
  54.  
  55.   <!--End RelatedTopics Section-->
  56.  
  57.     </div>
  58. </template>

 

Create Lightning Web Component JavaScript →

Step 2:- Create Lightning Web Component : lwcMultipleOptions.js

SFDX:Lightning Web Component >> New >> lwcMultipleOptions.js

lwcMultipleOptions.js [LWC JavaScript File]

  1.   import { LightningElement } from 'lwc';
  2.  
  3. export default class LwcMultipleOptions extends LightningElement {
  4.     selectedVal = [];
  5.  
  6.     get options() {
  7.         return [
  8.             { label: 'Salesforce LWC', value: 'Salesforce LWC' },
  9.             { label: 'Aura Component', value: 'Aura Component' },
  10.             { label: 'Visualforce Page', value: 'Visualforce Page' },
  11.             { label: 'Apex Trigger', value: 'Apex Trigger' },
  12.             { label: 'Javascript and JQuery', value: 'Javascript and JQuery' },
  13.             { label: 'W3web Tutorial', value: 'W3web Tutorial' },
  14.         ];
  15.     }
  16.  
  17.     get selected() {
  18.         return this.selectedVal.length ? this.selectedVal : 'none';
  19.     }
  20.  
  21.     handleChange(e) {
  22.         this.selectedVal = e.detail.value;
  23.     }
  24. }

 

Create Lightning Web Component Meta XML →

Step 3:- Create Lightning Web Component : lwcMultipleOptions.js-meta.xml

SFDX:Lightning Web Component >> New >> lwcMultipleOptions.js-meta.xml

lwcMultipleOptions.js-meta.xml [LWC Meta Data XML]

  1.    <?xml version="1.0" encoding="UTF-8"?>
  2. <LightningComponentBundle xmlns="http://soap.sforce.com/2006/04/metadata">
  3.     <apiVersion>45.0</apiVersion>
  4.     <isExposed>true</isExposed>
  5.     <targets> 
  6.         <target>lightning__AppPage</target>
  7.         <target>lightning__RecordPage</target>
  8.         <target>lightning__HomePage</target>
  9.     </targets>
  10. </LightningComponentBundle>

 

Create Lightning Application →

Step 4:- Create Lightning Application : lwcMultipleOptionsApp.app

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

lwcMultipleOptionsApp.app [Component Application File]

  1.   <aura:application extends="force:slds">
  2.     <c:lwcMultipleOptions/>
  3. </aura:application>

 
control multiple select options in lwc -- w3web.net
 

Further post that would you like to learn in Salesforce

 

 

FAQ (Frequently Asked Questions)

How do I create a multi select picklist using LWC?

To use a multi-select picklist in LWC, we need to use the standard lightning web component lightning-dual-listbox. First, create Lightning Web Component and import the getPicklistValues and getObjectInfo from lightning/uiObjectInfoApi module. We are importing getObjectInfo to get the Record Type details.

How do I create a multiple picklist in Salesforce?

Go to the fields area of the object you want to create a picklist field for. In the custom fields related list, click New. Select Picklist or Picklist and then click Next. Enter a label for the picklist field.

What is multi select dropdown?

Multi select dropdown list is used when a user wants to store multiple values for the same record, whereas dropdown list is used to store a single value for a record. You can create custom categories of either dropdown list or multi select dropdown list and define items in each category.

Related Topics | You May Also Like

 
Note:: – You will get an email, so put correct email and mobile number and BEGIN YOUR JOURNEY from Today!
 
 
  

Our Free Courses →

👉 Get Free Course →

📌 Salesforce Administrators

📌 Salesforce Lightning Flow Builder

📌 Salesforce Record Trigger Flow Builder

👉 Get Free Course →

📌 Aura Lightning Framework

📌 Lightning Web Component (LWC)

📌 Rest APIs Integration



Hi, This is Vijay Kumar 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. [Read full bio] | | The Sitemap where you can find all published post on w3web.net

Leave a Comment