Hi All,
I'm trying to create a LWC component which will show CRUD Matrix(i.e. which object has which permission for each profile), check image for more details.
For some reasons, i'm not able to see Object name and Profile name.
Below is the code:
HTML:
<template>
<div >
<template if:true={matrixList}>
<lightning-datatable
key-field="id"
data={matrixList}
columns={columns}>
</lightning-datatable>
</template>
</div>
</template>
JS:
import { LightningElement,api,track,wire } from 'lwc';
import getMatrix from '@salesforce/apex/CrudMatrixCls.getMatrix'
export default class CRUDMatrix extends LightningElement {
@track columns = [
{ label: 'ObjectName', fieldName: 'sObjectType'},
{ label: 'ProfileName', fieldName: 'Parent.Profile.name'},
{ label: 'Create', fieldName: 'PermissionsCreate',type: 'text'},
{ label: 'Read', fieldName: 'PermissionsRead',type: 'text'},
{ label: 'Edit', fieldName: 'PermissionsEdit',type: 'text'},
{ label: 'Delete', fieldName: 'PermiPermissionsDelete',type: 'text'},
{ label: 'ModifyAll', fieldName: 'PermissionsModifyAllRecords',type: 'text'},
{ label: 'ViewAll', fieldName: 'PermissionsViewAllRecords',type: 'text'}
];
@track matrixList;
@wire(getMatrix) wiredMatrix({data,error}){
if(data){
this.matrixList=data;
console.log(data);
}
else if(error){
console.log(error);
}
}
}
Class:
public with sharing class CrudMatrixCls {
@AuraEnabled(cacheable=true)
public static List<ObjectPermissions> getMatrix() {
return [SELECT sObjectType, Parent.Profile.Name,Parent.ProfileId, PermissionsCreate, PermissionsRead, PermissionsEdit, PermissionsDelete, PermissionsModifyAllRecords, PermissionsViewAllRecords FROM ObjectPermissions where Parent.Profile.Name != null order by sObjectType];
}
}