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
Jonathan Meltzer 8Jonathan Meltzer 8 

How to make Apex call in Subscribing Lightning Web Component and display information

Greetings!  I am creating a Lightning App Page where I am entering an account code into component A.  That code gets sent to component B via pub/sub, and component B sees it just fine.  I want component B to then make an Apex call to get records from another object (call it ACV) based on the account code that was sent from component A.  I have tried various combinations of @wire, @api, and @track, and have also tried to make the call in the event that is fired when the account code changes, but I cannot get the data from the ACV object to display in component B.  I know I am missing something basic, but I cannot find any examples of a component that subscribes to an event and then makes an Apex call to get records and display them.

Does anyone have an example of a pair of components that does this?  To recap:
Component A has an input field where the user enters an account code.  When the code changes, component A uses @wire to run Apex and get the Account record.  A fireEvent sends the new account record to component B, who is subscribed to it.
Component B runs a function when the event fires, and can display information related to the account record from Component A, but I want to run another Apex method to get ACV records associated with the account and display them in the HTML for component B.

I hope this explains what I want to do.  The APEX methods take a string parameter called searchTerm to do their searches, and return an array of records that should be size 1.

Thank you for any help.

Jonathan Meltzer 8Jonathan Meltzer 8
I found a way to do this.  It seems that you can use @wire the way I wanted to do it, but my syntax was off a bit.  Not even sure what the error was.