Posts

Showing posts from January, 2020

How to pass the user input from Child to Parent in Salesforce LWC

Image
video link ======= https://www.youtube.com/watch?v=Hh3nEIk9sws&t=227s childComponent.html =================== <template>     <lightning-input type="text"  style="width:15%;" label="FirstName" placeholder="Enter the FirstName"  onchange={handleChangeFirstName}>     </lightning-input> </template> childComponent.js ================= import { LightningElement,api } from 'lwc'; export default class ChildComponent extends LightningElement {     @api firstname;     handleChangeFirstName(event){         this.firstname=event.target.value;         const sampleEvent=new CustomEvent('inputcarryevent',{             detail:this.firstname         });         this.dispatchEvent(sampleEvent);     } } parentComponent.html ==================== <template>     <c-child-component oninputcarryevent={handlechange}>     </c-child-component>     FirstName is:{firstname}

How to display the records based on selected picklist value with event in LWC

Image
Apex class ========== public class AccountSearchController {     @AuraEnabled(cacheable=true)     public static List<Account> displayAccountRecords(String searchKey)     {         System.debug('searchKey'+searchKey);         List<Account> returnlist=new List<Account>();         for(Account acc:[select Name,Industry from Account where Industry=:searchKey])         {             returnlist.add(acc);         }         return returnlist;     } } childComponent.html =================== <template>     <template if:true={IndustryPicklistValues.data}>         <lightning-combobox name="progress"            label="Industry"            value={value}            placeholder="-Select-"            options={IndustryPicklistValues.data.values}            onchange={handleChange} >         </lightning-combobox>        </template> </template> childComponent.js ================

How to pass the value from one Component to other Component with event in LWC

Image
Video link ========= https://youtu.be/W9-ANZgxXZI Apex Class ========== public with sharing class AccountDemoController {     public AccountDemoController() {     }     @AuraEnabled(cacheable=true)     public static List<Account> displayAcntRecords(){         List<Account> acclist=[select Id,Name from Account LIMIT 5];         return acclist;     }     @AuraEnabled(cacheable=true)     public static List<Contact> displayConRecords(String accId){         System.debug('@@AccountId@@'+accId);         List<Contact> conlist=[select Id,LastName,AccountId from Contact where AccountId=:accId];         return conlist;     } } childComp2.html =============== <template> <b>Accounts</b>     <table class="slds-table slds-table_cell-buffer slds-table_bordered slds-m-top_small">         <tr>             <th>Select</th>             <th>AccountName</th>         </tr>

How to delete the records with a button in LWC

Image
Video link ======== https://www.youtube.com/watch?v=7rXycIcjHPM&t=71s Apex Class ========== public with sharing class AccountCls {     @AuraEnabled(cacheable=true)     public static List<Account> displayAccounts() {         List<Account> acclist=[select Id,Name from Account LIMIT 10];         return acclist; } } deleteAccountsData.html ======================= <template>     <template if:true={accounts}>         <table class="slds-table slds-table_cell-buffer slds-table_header-hidden"> <thead class="slds-assistive-text"> <tr class="slds-line-height_reset">   <th class="" scope="col"> <div class="slds-truncate" title="Account Name">Account Name</div>   </th>   <th class="" scope="col"> <div class="slds-truncate" title="Action">Actio

How to display the records based on selected picklist value in LWC

Image
AccountSearchController ======================= public class AccountSearchController {     @AuraEnabled(cacheable=true)     public static List<Account> displayAccountRecords(String searchKey)     {         System.debug('searchKey'+searchKey);         List<Account> returnlist=new List<Account>();         for(Account acc:[select Name,Industry from Account where Industry=:searchKey])         {             returnlist.add(acc);         }         return returnlist;     } } displayAccounts.html ==================== <template> <template if:true={IndustryPicklistValues.data}> <lightning-combobox name="progress"   label="Industry"   value={value}   placeholder="-Select-"   options={IndustryPicklistValues.data.values}   onchange={handleChange} > </lightning-combobox> </template><br/><br/> <template if:true={records}> <table>

How to display the Contacts based on Account Name in Lightning WebComponent

Image
Video link ========= https://www.youtube.com/watch?v=IkKFPHy29FU&t=16s Apex Class ========== public with sharing class AccountController {     @AuraEnabled(cacheable=true)     public  static List<Account> getAccounts()     {         List<Account> acclist=[select Id,Name from  Account LIMIT 5];         return acclist;     }     @AuraEnabled(cacheable=true)     public static List<Contact> getAllContacts(String searchKey)     {         System.debug('Entered into contact method');             List<Contact> returnconlist=new List<Contact>();         for(Contact con:[select LastName,Account.Name from Contact where Account.Name=:searchKey])         {             returnconlist.add(con);             System.debug('Contact list size'+returnconlist);         }         if(returnconlist.isEmpty())         {             System.debug('No Records found'+returnconlist.size());         }         return returnconl

Dynamic Search in Lightning WebComponent

Image
Video link ======== https://www.youtube.com/watch?v=i2_Zgw5OI_A&t=14s Apex class ========== public with sharing class ContactSearchController {     @AuraEnabled(cacheable=true)     public static List<Contact> getAllContacts(String searchKey)     {         List<Contact> returnconlist=new List<Contact>();         String searchWord='%'+searchKey+'%';         for(Contact con:[select LastName from Contact where LastName like:searchWord])         {             returnconlist.add(con); }         if(returnconlist.isEmpty())         {             System.debug('No Records found'+returnconlist.size());         }         return returnconlist;         } }      conSearch.html ============== <template>     <lightning-card title="ContactSearchFunctionality" icon-name="custom:custom63">         <lightning-input label="Enter LastName"  style="width:50%;" placeholde