You need to sign in to do that
Don't have an account?
Ap30
How to show list of records matching two field values in component using lwc
Hi All,
There are objects Vendor__c and Placement__c which are not related to each other. In component 1, I have two picklists "state" and "company".
On giving values to "state and company" and clicking "select" button, it should lists all the records matching state and company from object "Placement__c" in component 2.
Any help is appreciated.
VendorComponent
==============
<template>
<lightning-record-edit-form object-api-name="Vendor__c">
<lightning-input-field field-name="Vendor_First_Name__c"></lightning-input-field>
<lightning-input-field field-name="Vendor_Last_Name__c"></lightning-input-field>
<lightning-input-field field-name="Vendor_Phone__c" type="tel"></lightning-input-field>
<lightning-input-field field-name="Vendor_Email__c"></lightning-input-field>
<lightning-combobox
name="st"
label="State"
value={value1}
placeholder="Select State"
options={options1}
onchange={handleChange1} ></lightning-combobox>
<lightning-combobox
name="Com"
label="Company"
value={value2}
placeholder="Select Company"
options={options2}
onchange={handleChange2} ></lightning-combobox>
<lightning-button class="slds-m-top_small" variant="brand" type="submit" label="SAVE" onclick = {navigateToLightningComponent}></lightning-button>
</lightning-record-edit-form>
</template>
==============================================
import { LightningElement,wire,api} from 'lwc';
import { NavigationMixin } from 'lightning/navigation';
export default class VendorComponent extends LightningElement {
get options1() {
return [
{ label: 'Delhi', value: 'del' },
{ label: 'Maharashtra', value: 'mah' },
{ label: 'Kerala', value: 'ker' },
];
}
get options2() {
return [
{ label: 'Company1', value: '1c' },
{ label: 'Company2', value: '2c' },
{ label: 'Company3', value: '3c' },
];
}
navigateToLightningComponent() {
this[NavigationMixin.Navigate]({
"type": "custom__component",
"attributes": {
"componentName": "c__payComponent"
}
});
}
}
==============================================
<?xml version="1.0" encoding="UTF-8"?>
<LightningComponentBundle xmlns="http://soap.sforce.com/2006/04/metadata">
<apiVersion>51.0</apiVersion>
<isExposed>true</isExposed>
<targets>
<target>lightning__AppPage</target>
<target>lightning__RecordPage</target>
<target>lightning__HomePage</target>
</targets>
</LightningComponentBundle>
There are objects Vendor__c and Placement__c which are not related to each other. In component 1, I have two picklists "state" and "company".
On giving values to "state and company" and clicking "select" button, it should lists all the records matching state and company from object "Placement__c" in component 2.
Any help is appreciated.
VendorComponent
==============
<template>
<lightning-record-edit-form object-api-name="Vendor__c">
<lightning-input-field field-name="Vendor_First_Name__c"></lightning-input-field>
<lightning-input-field field-name="Vendor_Last_Name__c"></lightning-input-field>
<lightning-input-field field-name="Vendor_Phone__c" type="tel"></lightning-input-field>
<lightning-input-field field-name="Vendor_Email__c"></lightning-input-field>
<lightning-combobox
name="st"
label="State"
value={value1}
placeholder="Select State"
options={options1}
onchange={handleChange1} ></lightning-combobox>
<lightning-combobox
name="Com"
label="Company"
value={value2}
placeholder="Select Company"
options={options2}
onchange={handleChange2} ></lightning-combobox>
<lightning-button class="slds-m-top_small" variant="brand" type="submit" label="SAVE" onclick = {navigateToLightningComponent}></lightning-button>
</lightning-record-edit-form>
</template>
==============================================
import { LightningElement,wire,api} from 'lwc';
import { NavigationMixin } from 'lightning/navigation';
export default class VendorComponent extends LightningElement {
get options1() {
return [
{ label: 'Delhi', value: 'del' },
{ label: 'Maharashtra', value: 'mah' },
{ label: 'Kerala', value: 'ker' },
];
}
get options2() {
return [
{ label: 'Company1', value: '1c' },
{ label: 'Company2', value: '2c' },
{ label: 'Company3', value: '3c' },
];
}
navigateToLightningComponent() {
this[NavigationMixin.Navigate]({
"type": "custom__component",
"attributes": {
"componentName": "c__payComponent"
}
});
}
}
==============================================
<?xml version="1.0" encoding="UTF-8"?>
<LightningComponentBundle xmlns="http://soap.sforce.com/2006/04/metadata">
<apiVersion>51.0</apiVersion>
<isExposed>true</isExposed>
<targets>
<target>lightning__AppPage</target>
<target>lightning__RecordPage</target>
<target>lightning__HomePage</target>
</targets>
</LightningComponentBundle>
Can you elaborate with an example to check further and respond back.
Thanks.
Hi !! For example, object "Vendor__c" has fields firstname,lastname,phone,email and object "Placement__c" has fields placement code,state(picklist),company(picklist). In component 1, we have firstname,lastname,phone,email,state and company picklist input fields and on clicking SELECT button data has to be sent to database(object vendor__c) and also it should show list of placement code in component 2, matchinig state and company given in compoonent 1.