Last active
April 14, 2020 22:11
-
-
Save hrendoh/a9d80a01a3bbe6583bdc3a352d9b37de to your computer and use it in GitHub Desktop.
Usage of getListUi function
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<template> | |
<lightning-card title="List view Labels"> | |
<ul> | |
<li>{contactLabel}</li> | |
<li>{myObjectLabel}</li> | |
</ul> | |
</lightning-card> | |
</template> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { LightningElement, wire } from 'lwc'; | |
import { getListUi } from 'lightning/uiListApi'; | |
import CONTACT_OBJECT from '@salesforce/schema/Contact'; | |
// In case of a custom object, this will not compile, so specify objectApiName directly | |
// import DIRECTORY_OBJECT from '@salesforce/schema/namespace__AllMyObjects__c'; | |
export default class HelloListUi extends LightningElement { | |
@wire(getListUi, { objectApiName: CONTACT_OBJECT, listViewApiName: 'namespace__AllContacts' }) | |
contactListUi; | |
@wire(getListUi, { objectApiName: 'namespace__myObject__c', listViewApiName: 'namespace__AllMyObjects' }) | |
myObjectListUi; | |
get contactLabel() { | |
return this.contactListUi.data ? this.contactListUi.data.info.label : ''; | |
} | |
get myObjectLabel() { | |
return this.myObjectListUi.data ? this.myObjectListUi.data.info.label : ''; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment