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];
}
}