Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to split values from multiple picklist to dropdown value in salesforce LWC #90

Open
vijayk3327 opened this issue Jul 17, 2023 · 0 comments
Assignees
Labels
documentation Improvements or additions to documentation question Further information is requested

Comments

@vijayk3327
Copy link
Owner

In this post we are going to learn about How to split values from multiple picklist to dropdown value in salesforce LWC.

A Picklist provides a user with an select-only component that is functionally similar to an HTML select element. It is accompanied with a listbox of pre-defined options. A picklist has both single and multi-selection patterns.

→ Get source code live demo link:-

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

`

        <div class="slds-col slds-size_6-of-12">
            <div class="slds-form-element">               
                <div class="slds-form-element_controller">
                   <lightning-record-edit-form object-api-name="Contact">
                       <lightning-input-field field-name="AccountId" data-type="input-field" value={accountId} name="accountId" onchange={handleChangeAction}>
                       </lightning-input-field>
                   </lightning-record-edit-form>   
                </div>
            </div>
        </div>

        <div class="slds-col slds-size_6-of-12">
            <div class="slds-form-element">               
                <div class="slds-form-element_controller">
                   <lightning-record-edit-form object-api-name="Contact">
                       <lightning-input-field field-name="ReportsToId" data-type="input-field" value={reportsToId} name="reportsToId" onchange={handleChangeAction}>
                       </lightning-input-field>
                   </lightning-record-edit-form>   
                </div>
            </div>
        </div>

     </div>
</lightning-card>

`

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

` import { LightningElement,track, api } from 'lwc';

export default class LookupFieldValueLwc extends LightningElement {
@track accountId ;
@track reportsToId;

handleChangeAction(event){
    if(event.target.name == 'accountId'){
        this.accountId = event.target.value;  
        //window.console.log('accountId ##' + this.accountId);
        if(this.accountId == '0015g00000y2ZQEAA2')
        {
            this.reportsToId = '0035g00000FroJAAAZ';
        }else{
            this.reportsToId = '';
        }
        
    }
    if(event.target.name == 'reportsToId'){
        this.reportsToId = event.target.value;  
        window.console.log('reportsToId ##' + this.reportsToId);
    }
}

}`

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

<?xml version="1.0" encoding="UTF-8"?> <LightningComponentBundle xmlns="http://soap.sforce.com/2006/04/metadata"> <apiVersion>56.0</apiVersion> <isExposed>true</isExposed> <targets> <target>lightning__AppPage</target> <target>lightning__RecordPage</target> <target>lightning__HomePage</target> </targets> </LightningComponentBundle>

→ Get source code live demo link:-

@vijayk3327 vijayk3327 added documentation Improvements or additions to documentation question Further information is requested labels Jul 17, 2023
@vijayk3327 vijayk3327 self-assigned this Jul 17, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation question Further information is requested
Projects
Status: No status
Development

No branches or pull requests

1 participant