function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Ap30Ap30 

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>
ANUTEJANUTEJ (Salesforce Developers) 
Hi Anupriya,

Can you elaborate with an example to check further and respond back.

Thanks.
Ap30Ap30
@Anutej
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.
flavia dcosta 2flavia dcosta 2
@Ap30 - did you get a resolution to this issue? if so kindly paste the same below, thanks