function readOnly(count){ }
Don't have an account?
Search for an answer or ask a question of the zone or Customer Support.
You need to sign in to do that
Sign in to start searching questions
Signup for a Developer Edition
Sign in to start a discussion
<template> <ul> <template for:each={accounts} for:item="account"> <li key={account.Id}> <div>{account.Name}</div> <div>{account.Email}</div> <ul> <template for:each={account.Contacts} for:item="contact"> <li key={contact.Id}>{contact.Name} - {contact.Email}</li> </template> </ul> </li> </template> </ul> </template>
import { LightningElement, wire } from 'lwc'; import getAccountsAndContacts from '@salesforce/apex/AccountController.getAccountsAndContacts'; export default class AccountsWithContacts extends LightningElement { accounts = []; @wire(getAccountsAndContacts) wiredAccounts({ error, data }) { if (data) { this.accounts = data; } else if (error) { console.error(error); } } }
public with sharing class AccountController { @AuraEnabled(cacheable=true) public static List<Account> getAccountsAndContacts() { List<Account> accounts = [SELECT Id, Name, Email, (SELECT Id, Name, Email FROM Contacts) FROM Account]; return accounts; } }
I have came across a discussion which might help you with your requirement -> https://developer.salesforce.com/forums/?id=9062I000000DLDKQA4
Hope the above information helps !
Thank you.
here is the example LWC component you can use to achive your logic
HTML: Javascript:
Controller:
Hope this helps you yo achieve what you wanted