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
Lalitha Jakka 18Lalitha Jakka 18 

account related order, opportunity in LWC

I have an object called Invoice, which has account, order, and opportunity as lookup fields. I have overridden the Inoice New button, on new invoice record creation, when I select Account, respective order and opportunity records want to show in the lookup fields to select.
Currently, I am using 
 <lightning-input-field field-name="Order__c" onchange={handleOrderSelection}></lightning-input-field>
where it displays record records

Thanks in Advance !!
SubratSubrat (Salesforce Developers) 
Hello laitha ,

Are you facing any Error or the records are not showing up ? 
Can you please elaborate.

Thank you.
Santosh Joshi 11Santosh Joshi 11
Based on what you've described, you have an object called "Invoice" which has lookup fields for "Account", "Order", and "Opportunity". When you create a new invoice record, you've overridden the New button so that when you select an Account, the respective Order and Opportunity records should display in their respective lookup fields for you to select.

To achieve this, you're currently using the Lightning input field component with the "Order__c" field name and an "onchange" event handler called "handleOrderSelection". This component displays the related Order records based on the selected Account.

Is there anything else you need help with related to this topic?
Lalitha Jakka 18Lalitha Jakka 18

@Subrat 

No, I am not facing any issues but when I select an account, in order lookup field, it shows recent records instead of account related order records

Lalitha Jakka 18Lalitha Jakka 18
@Santosh Joshi 11

No, I am not getting related records, it shows recent records
Lalitha Jakka 18Lalitha Jakka 18
User-added image
Carolyn Maselli 3Carolyn Maselli 3
Here is a quick breakdown of our changes to the LWC:
formfill.html
After speaking with Danielle, “Amount”, “Next Steps”, and “Stage” are the three key fields that the team are constantly updating, so we add these fields as inputs. Let’s add “Opportunity Name” as an output as well, just for the visual.  MyBalanceNow (https://www.mybalancenow.page/)

<template>
    <lightning-quick-action-panel header="Edit Fields Action">
        <lightning-record-edit-form record-id={recordId}
                                    object-api-name={objectApiName}
                                    onsuccess={handleSuccess}>
            <lightning-output-field field-name="Name"></lightning-output-field>
            <lightning-input-field field-name="Amount"></lightning-input-field>
            <lightning-input-field field-name="NextStep"></lightning-input-field>
            <lightning-input-field field-name="StageName"></lightning-input-field>
            <lightning-button variant="neutral" label="Cancel"></lightning-button>
            <lightning-button variant="brand" class="slds-m-left_x-small" label="Save" type="submit"></lightning-button>
        </lightning-record-edit-form>
    </lightning-quick-action-panel>
</template>

 
Lalitha Jakka 18Lalitha Jakka 18
@Carolyn Maselli 3 how the solution you provided is helpful to me?