You need to sign in to do that
Don't have an account?
Tulasiram Chippala
Displaying no data available in Lightning Web Components
I am using the below code and placed that component in the Home page using app builder. But it is displaying No Data available.
js code:
xml:
Where i am doing a mistake.
<template> <template if:true={contact}> <lightning-layout vertical-align="center"> <lightning-layout-item padding="around-small"> <p>{contact.Name}</p> <p>{contact.Title}</p> <p> <lightning-formatted-phone value={contact.Phone} ></lightning-formatted-phone> </p> </lightning-layout-item> </lightning-layout> </template> <template if:false={contact} ><p>No contact data available.</p></template > </template>
js code:
import { LightningElement, api } from 'lwc'; export default class ContactTile extends LightningElement { @api contact; }
xml:
<?xml version="1.0" encoding="UTF-8"?> <LightningComponentBundle xmlns="http://soap.sforce.com/2006/04/metadata"> <apiVersion>45.0</apiVersion> <isExposed>true</isExposed> <targets> <target>lightning__AppPage</target> <target>lightning__RecordPage</target> <target>lightning__HomePage</target> </targets> <targetConfigs> <targetConfig targets="lightning__RecordPage"> <objects> <object>contact</object> </objects> </targetConfig> </targetConfigs> </LightningComponentBundle>
Where i am doing a mistake.
https://developer.salesforce.com/docs/component-library/documentation/lwc/lwc.data_wire_example
Greetings to you!
To get the data, you need to use the getRecord wire adapter. Please refer to the below links which might help you further with the above requirement.
https://developer.salesforce.com/docs/component-library/documentation/lwc/lwc.data_wire_example
https://medium.com/@tempflip/wiring-up-lightning-web-components-26b1c00d247d
https://sfdccoder.wordpress.com/2019/02/21/lightning-web-component-load-contacts-list-example/
I hope it helps you.
Kindly let me know if it helps you and close your query by marking it as solved so that it can help others in the future. It will help to keep this community clean.
Thanks and Regards,
Khan Anas
You can use lightning-record-form, lightning-record-edit-form, or lightning-record-view-form components.
You can check more details here.
https://newstechnologystuff.com/2018/12/16/lightning-web-component-the-new-development-style/
https://developer.salesforce.com/docs/component-library/documentation/lwc/lwc.data_ui_api
Thanks
Tushar
https://newstechnologystuff.com/