You need to sign in to do that
Don't have an account?
Sandeep Ekambe
Account Record data using APEX wire LWC cannot be inserted in a recordpage
Created a LWC to display Account Record data using the APEX wire method, after pushing the code to the scratch org, created a new Lightning Account record page, was trying to drag and drop the above LWC onto this page but this throws below error
Below is the code
.js code
.html code
GetAccountData.cls APEX code
Below is the code
.js code
import { LightningElement, wire } from 'lwc'; import getAccountList from '@salesforce/apex/GetAccountData.getAccountList'; export default class LWCWireEx extends LightningElement { @wire(getAccountList) accounts; }
.html code
<template> <lightning-card title="Apex Class Example(lWCWireEx compo)" icon-name="custom:custom63"> <div class="slds-m-around_medium"> <template if:true={accounts.data}> <template for:each={accounts.data} for:item="acc"> <p key={acc.Id}>{acc.Name}</p> </template> </template> </div> </lightning-card> </template>
GetAccountData.cls APEX code
public with sharing class GetAccountData { @AuraEnabled(cacheable=true) public static List<Account> getAccountList() { return [SELECT Id, Name,Type,Rating,Phone FROM Account]; } }