Skip to content

Instantly share code, notes, and snippets.

@hrendoh
Last active April 14, 2020 22:11
Show Gist options
  • Save hrendoh/a9d80a01a3bbe6583bdc3a352d9b37de to your computer and use it in GitHub Desktop.
Save hrendoh/a9d80a01a3bbe6583bdc3a352d9b37de to your computer and use it in GitHub Desktop.
Usage of getListUi function
<template>
<lightning-card title="List view Labels">
<ul>
<li>{contactLabel}</li>
<li>{myObjectLabel}</li>
</ul>
</lightning-card>
</template>
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