I have a combobox populated with listviews from an object. If I select a listview, those records have to be shown in the table. But the records of a selected object are not being updated unless I select another listview. Then the previous selected values are being shown. If I want the values of second time selected listview I need to click again the first listview or another listview. Only then the second listview records are being shown.

import { LightningElement,wire,track,api} from 'lwc';
import { getListUi} from 'lightning/uiListApi';
import PRODUCT_OBJECT from '@salesforce/schema/Product2';

export default class ShowListView extends LightningElement {

@track allListViews;
@track Value;   

@wire(getListUi, {objectApiName: PRODUCT_OBJECT})
wiredlistView({error,data}) {
        this.allListViews = data.lists;
        var listViewData = [];
    for(var i=0;i<this.allListViews.length;i++){
        listViewData.push({"label" : this.allListViews[i].label, "value" : 
    this.allListViews = listViewData;
    }else if(error){
        console.log('An error has occurred:');

@wire(getListUi, {objectApiName: PRODUCT_OBJECT,listViewApiName: '$Value'})
    if (data) {
        this.sobjectResult = data.records.records;  
    } else if (error) {
        this.error = error;
handleChange(event) {

How do I achieve this?

<lightning-card title=" List View Example" icon-name="standard:action_list_component">
        label="Picklist Value"
        placeholder="Select a ListView"
    <p>Selected Value is: {Value}</p>
    <table class="slds-table slds-table_cell-buffer slds-table_bordered">
            <tr class="slds-line-height_reset">
                <th >
                    <div >Price Book</div>
                    <div >Product Name</div>
                    <div>Product Code</div>
                    <div>Product Family</div>
            <template if:true={sobjectResult}>
                <template for:each={sobjectResult} for:item="so">
                    <tr class="slds-hint-parent" key={so.id}>
                        <td >{so.id}</td>
                        <td > {so.fields.Name.value}</td>
                        <td > {so.fields.ProductCode.value}</td>
                        <td > {so.fields.Family.value}</td>
            <template if:false={sobjectResult}>
                List View is not contains any data

This is the template

  • Maybe a problem with your template. I tested your code and it seems working for me. can you share your template code?
    – Klecool
    Jul 14, 2020 at 7:14
  • @Klecool. Updated in the body. Jul 14, 2020 at 10:28

1 Answer 1


You did not declare the sobjectResult in your js and that was the cause of unexpected behavior. You just need to add it to your js.
Also, note since the Spring '20 Release, the @track decorator is no longer required.

export default class ShowListView extends LightningElement {

@track allListViews;
@track Value;
  • Thanks a lot. Working perfectly Jul 14, 2020 at 11:12
  • You 're welcome!
    – Klecool
    Jul 14, 2020 at 11:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.