You need to sign in to do that
Don't have an account?
jaishri
Hi , I want to filter the input fields of account like annual revenue,rating,type ,website and show the output in the form of datatable on button click can anyone help me i didn't get how to filter all fields on button click i have code also
accountForm.html <template> <div class="slds-p-around_medium lgc-bg"> <lightning-input type="Currency" label="AnnualRevenue Start"></lightning-input> </div> <div class="slds-p-around_medium lgc-bg"> <lightning-input type="Currency" label="AnnualRevenue End"></lightning-input> </div> <div class="slds-p-around_medium lgc-bg"> <template if:true={typeValues.data}> <lightning-combobox name="Type" label="Type" value={value} options={typeValues.data.values} onchange={handleChange} > </lightning-combobox> </template> </div> <div class="slds-p-around_medium lgc-bg"> <template if:true={ratingValues.data}> <lightning-combobox name="Rating" label="Rating" value={value} options={ratingValues.data.values} onchange={handleChange} > </lightning-combobox> </template> </div> <div class="slds-p-around_medium lgc-bg"> <template if:true={industryValues.data}> <lightning-combobox name="Industry" label="Industry" value={value} options={industryValues.data.values} onchange={handleChange}> </lightning-combobox> </template> </div> <lightning-button type="submit" variant="brand" label="Show Accounts" onclick={handleClick} ></lightning-button> <c-account-datatable if:true={showSearchComponent}></c-account-datatable> </template> accountForm.js import { LightningElement, wire,track } from 'lwc'; import { getPicklistValues } from 'lightning/uiObjectInfoApi'; import Type from '@salesforce/schema/Account.Type'; import Rating from '@salesforce/schema/Account.Rating'; import { getObjectInfo } from 'lightning/uiObjectInfoApi'; import ACCOUNT_OBJECT from '@salesforce/schema/Account'; import Industry from '@salesforce/schema/Account.Industry'; export default class AccountForm extends LightningElement { @track showSearchComponent = false; searchKey = ''; accounts; error; @wire(getObjectInfo, { objectApiName: ACCOUNT_OBJECT }) accountInfo; nameVal; typeVal; industryVal; @wire(getPicklistValues, { recordTypeId: '$accountInfo.data.defaultRecordTypeId', fieldApiName: Type }) typeValues; @wire(getPicklistValues, { recordTypeId: '$accountInfo.data.defaultRecordTypeId', fieldApiName: Rating }) ratingValues; @wire(getPicklistValues, { recordTypeId: '$accountInfo.data.defaultRecordTypeId', fieldApiName: Industry }) industryValues; handleChange(event){ var fieldname = event.target.label; if(fieldname == 'Rating'){ this.nameVal= event.target.value; } else if(fieldname == 'Type'){ this.typeVal = event.target.value; }else if (fieldname == 'Industry'){ this.industryVal = event.target.value; } if(this.nameVal== 'Hot' && this.typeVal == 'Prospect' && this.industryVal =='Agriculture'){ this.hideBtn = true; }else{ this.hideBtn = false; } } handleonchange(event){ this.searchKey = event.target.value; } handleClick() { this.showSearchComponent = true; findAccountList({keyword: this.searchKey}) .then((result) =>{ this.accounts = result; this.error = undefined; }) .catch((error)=>{ this.error = error; this.accounts = undefined; }); } } accountDatatble.html <template> <lightning-datatable key-field="Id" data={accounts.data} columns={columns} ></lightning-datatable> </template> accountDatatble.js import { LightningElement, wire } from 'lwc'; import getAccountList from '@salesforce/apex/AccountForm.getAccountList'; const columns = [ { label: 'AnnualRevenue', fieldName: 'AnnualRevenue', type:'currency' }, { label: 'Industry', fieldName: 'Industry' }, { label: 'Type', fieldName: 'Type' }, { label: 'Rating', fieldName: 'Rating', type: 'picklist' }, { label: 'Website', fieldName: 'Website', type: 'url' }, ]; export default class AccountDatatble extends LightningElement { error; columns = columns; @wire(getAccountList) accounts; } AccountForm.cls public with sharing class AccountForm { @AuraEnabled(cacheable=true) public static List<Account> getAccountList(String searchKey) { String key = '%' + searchKey + '%'; return [SELECT Id, Industry, Type, Rating, AnnualRevenue,Website FROM Account WHERE Type = :searchKey LIMIT 10]; }