Skip to main content
added 246 characters in body
Source Link
sfdcfox
  • 501.7k
  • 21
  • 473
  • 828

Code below: import {LightningElement, track, wire} from 'lwc'; import getOppdata from '@salesforce/apex/LWCExampleController.retriveOpportunities'; const columns = [ { label: 'User', fieldName: 'UserOrGroupName', type: 'text', }, { label: 'AccessLevel', fieldName: 'OpportunityAccessLevel', type: 'text' } ] export default class OpptyAccountLWC extends LightningElement { @track data = []; @track columns = columns;

import {LightningElement, track, wire} from 'lwc';
import getOppdata from '@salesforce/apex/LWCExampleController.retriveOpportunities';
const columns = [
    {
        label: 'User',
        fieldName: 'UserOrGroupName',
        type: 'text',
    },
     {
        label: 'AccessLevel',
        fieldName: 'OpportunityAccessLevel',
        type: 'text'
    }
]
export default class OpptyAccountLWC extends LightningElement {
    @track data = [];
    @track columns = columns;

    @wire(getOppdata)
    opp({error, data}) {
        if(data) {

            let currentData = [];

            data.forEach((row) => {

                let rowData = {};

                rowData.User = row.UserOrGroup.Name;
                rowData.AccessLevel = row.OpportunityAccessLevel;
                //window.alert('########## '+row.UserOrGroup.Name );
                //console.log('########### '+ row.UserOrGroup.Name);

                currentData.push(rowData);
            });

            this.data = currentData;
        }
        else if(error) {
            window.console.log(error);
        }
    }
}

}

<template>
    <lightning-card title="OpptyShareRecords">
        <lightning-datatable columns={columns} 
                            data={data} 
                            key-field="id"
                            hide-checkbox-column="true"
                            show-row-number-column="true"></lightning-datatable>
    </lightning-card>
</template>

public class LWCExampleController {
@AuraEnabled(cacheable=true) public static list retriveOpportunities() { return [SELECT OpportunityAccessLevel,UserOrGroup.Name FROM OpportunityShare]; } }

public class LWCExampleController {    
    @AuraEnabled(cacheable=true)
    public static list<OpportunityShare> retriveOpportunities() {
        return [SELECT OpportunityAccessLevel,UserOrGroup.Name
                FROM OpportunityShare];
    }
}

Code below: import {LightningElement, track, wire} from 'lwc'; import getOppdata from '@salesforce/apex/LWCExampleController.retriveOpportunities'; const columns = [ { label: 'User', fieldName: 'UserOrGroupName', type: 'text', }, { label: 'AccessLevel', fieldName: 'OpportunityAccessLevel', type: 'text' } ] export default class OpptyAccountLWC extends LightningElement { @track data = []; @track columns = columns;

@wire(getOppdata)
opp({error, data}) {
    if(data) {

        let currentData = [];

        data.forEach((row) => {

            let rowData = {};

            rowData.User = row.UserOrGroup.Name;
            rowData.AccessLevel = row.OpportunityAccessLevel;
            //window.alert('########## '+row.UserOrGroup.Name );
            //console.log('########### '+ row.UserOrGroup.Name);

            currentData.push(rowData);
        });

        this.data = currentData;
    }
    else if(error) {
        window.console.log(error);
    }
}

}

public class LWCExampleController {
@AuraEnabled(cacheable=true) public static list retriveOpportunities() { return [SELECT OpportunityAccessLevel,UserOrGroup.Name FROM OpportunityShare]; } }

Code below:

import {LightningElement, track, wire} from 'lwc';
import getOppdata from '@salesforce/apex/LWCExampleController.retriveOpportunities';
const columns = [
    {
        label: 'User',
        fieldName: 'UserOrGroupName',
        type: 'text',
    },
     {
        label: 'AccessLevel',
        fieldName: 'OpportunityAccessLevel',
        type: 'text'
    }
]
export default class OpptyAccountLWC extends LightningElement {
    @track data = [];
    @track columns = columns;

    @wire(getOppdata)
    opp({error, data}) {
        if(data) {

            let currentData = [];

            data.forEach((row) => {

                let rowData = {};

                rowData.User = row.UserOrGroup.Name;
                rowData.AccessLevel = row.OpportunityAccessLevel;
                //window.alert('########## '+row.UserOrGroup.Name );
                //console.log('########### '+ row.UserOrGroup.Name);

                currentData.push(rowData);
            });

            this.data = currentData;
        }
        else if(error) {
            window.console.log(error);
        }
    }
}
<template>
    <lightning-card title="OpptyShareRecords">
        <lightning-datatable columns={columns} 
                            data={data} 
                            key-field="id"
                            hide-checkbox-column="true"
                            show-row-number-column="true"></lightning-datatable>
    </lightning-card>
</template>
public class LWCExampleController {    
    @AuraEnabled(cacheable=true)
    public static list<OpportunityShare> retriveOpportunities() {
        return [SELECT OpportunityAccessLevel,UserOrGroup.Name
                FROM OpportunityShare];
    }
}
Source Link

LWC Data table returning blank rows

I am trying to display opportunity share records in lwc data table, I am getting blank rows even though when i execute the query in the workbench, records are being returned with values.

Code below: import {LightningElement, track, wire} from 'lwc'; import getOppdata from '@salesforce/apex/LWCExampleController.retriveOpportunities'; const columns = [ { label: 'User', fieldName: 'UserOrGroupName', type: 'text', }, { label: 'AccessLevel', fieldName: 'OpportunityAccessLevel', type: 'text' } ] export default class OpptyAccountLWC extends LightningElement { @track data = []; @track columns = columns;

@wire(getOppdata)
opp({error, data}) {
    if(data) {

        let currentData = [];

        data.forEach((row) => {

            let rowData = {};

            rowData.User = row.UserOrGroup.Name;
            rowData.AccessLevel = row.OpportunityAccessLevel;
            //window.alert('########## '+row.UserOrGroup.Name );
            //console.log('########### '+ row.UserOrGroup.Name);

            currentData.push(rowData);
        });

        this.data = currentData;
    }
    else if(error) {
        window.console.log(error);
    }
}

}

HTML:

Controller class:

public class LWCExampleController {
@AuraEnabled(cacheable=true) public static list retriveOpportunities() { return [SELECT OpportunityAccessLevel,UserOrGroup.Name FROM OpportunityShare]; } }