You need to sign in to do that
Don't have an account?
Surya Pratap Singh 13
AccountFinder.html :-
AccountFinder.js :-
AccountFinder.xml :-
Work with Salesforce Data trailhead solution -( Create an Apex controller and wire a method that returns account records filtered by annual revenue.)
public with sharing class AccountListControllerLwc { @AuraEnabled(cacheable=true) public static Account queryAccountsByRevenue(Decimal annualRevenue){ return [ SELECT Name FROM Accoun WHERE AnnualRevenue >= :annualRevenue ]; } }
AccountFinder.html :-
<template> <lightning-card> <lightning-input type="number" label="Annual Revenue" formatter="currency" value={annualRevenue} onchange={handleChange}> </lightning-input> <lightning-button label="reset" onclick={reset}> </lightning-button> <template if:true={accounts.data}> <template for:each={accounts.data} for:item="account"> <p key={account.Id}>{account.Name}</p> </template> </template> </lightning-card> </template>
AccountFinder.js :-
import { LightningElement,wire } from 'lwc'; import queryAccountsByRevenue from '@salesforce/apex/AccountListControllerLwc.queryAccountsByRevenue'; export default class AccountFinder extends LightningElement { annualRevenue = null; handleChange(event){ this.annualRevenue = event.detail.value; } reset(){ this.annualRevenue= null; } @wire(queryAccountsByRevenue ,{annualRevenue : '$annualRevenue'}) accounts; }
AccountFinder.xml :-
<?xml version="1.0" encoding="UTF-8"?> <LightningComponentBundle xmlns="http://soap.sforce.com/2006/04/metadata"> <apiVersion>52.0</apiVersion> <isExposed>true</isExposed> <targets> <target>lightning__AppPage</target> <target>lightning__RecordPage</target> <target>lightning__HomePage</target> </targets> </LightningComponentBundle>
Please note that Questions about how to pass Trailhead challenges are not on topic, because these challenges are intended to be independent demonstrations of your abilities.Trailhead Help (https://trailhead.salesforce.com/en/help?support=home)can provide assistance for situations where Trailhead does not appear to be functioning correctly. You can reach out to them if this is the case.
Thanks!
@wire is a property useful when you want to consume the data, If the property decorate with @wire is used as an attribute in the template and
its value changes according to the Data, the @wire property requests the data and triggers the component to rerender.
you can learn about Wire In LWC from this module and can complete this challenge :
https://trailhead.salesforce.com/en/content/learn/modules/lightning-web-components-and-salesforce-data/use-apex-to-work-with-data?trail_id=build-lightning-web-components
https://developer.salesforce.com/docs/component-library/documentation/en/lwc/lwc.data_wire_service_about
If you find your Solution then mark this as the best answer.
Thank you!
Regards,
Suraj Tripathi