on the wired with function example you did not show how would you then resent the name on the front end. so on the 'accounts' property how would you display the returned name on the front end
I am getting Object object in logs and not getting data visible in Component HTML, Could you please suggest what could went wrong below? Thanks JS------------------- import { getRecord } from 'lightning/uiRecordApi'; import { LightningElement, api, wire } from 'lwc'; import ACCOUNT_NAME_FIELD from '@salesforce/schema/Account.Name'; export default class WireWithFunction extends LightningElement { @api recordId; accounts; error; @wire(getRecord, { recordId: '$recordId', fields: [ACCOUNT_NAME_FIELD] }) wiredAccount({ error, data }) { if (data) { this.accounts = data; this.error = undefined; console.log(`##Getting Data from wire with function: ${this.accounts}`); } else if (error) { this.error = error; this.accounts = undefined; console.log("##Error Occured while fetching data: " + error.body.message); } } } HTML-----------------
Account Name : {accounts.fields.Name.value} Account Number : {accounts.fields.AccountNumber.value}
on the wired with function example you did not show how would you then resent the name on the front end. so on the 'accounts' property how would you display the returned name on the front end
It's the same way he did in previous example, using accounts variable in html
I am getting Object object in logs and not getting data visible in Component HTML, Could you please suggest what could went wrong below? Thanks
JS-------------------
import { getRecord } from 'lightning/uiRecordApi';
import { LightningElement, api, wire } from 'lwc';
import ACCOUNT_NAME_FIELD from '@salesforce/schema/Account.Name';
export default class WireWithFunction extends LightningElement {
@api
recordId;
accounts;
error;
@wire(getRecord, { recordId: '$recordId', fields: [ACCOUNT_NAME_FIELD] })
wiredAccount({ error, data }) {
if (data) {
this.accounts = data;
this.error = undefined;
console.log(`##Getting Data from wire with function: ${this.accounts}`);
}
else if (error) {
this.error = error;
this.accounts = undefined;
console.log("##Error Occured while fetching data: " + error.body.message);
}
}
}
HTML-----------------
Account Name : {accounts.fields.Name.value}
Account Number : {accounts.fields.AccountNumber.value}
Great
Keep watching
Thank you
Keep watching
sir can you please share the PPT ?
Available on our blog post