function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Abhishek AS 3Abhishek AS 3 

I have a requirement to create a lwc component that will show the related cases of a contact on case record

I have to display related cases (like 3 fields of case) of a contact on case record using lwc component. 
AnkaiahAnkaiah (Salesforce Developers) 
Hi Abhishek,

Refer the below link and modify the code as per your requirement.
https://www.codekiat.com/2020/04/how-to-pass-record-id-from-lightning-web-component-to-apex-controller.html

If this helps, Please mark it as best answer.

Thanks!!
CharuDuttCharuDutt
Hii Abhishek
Try Below Code
<template>
  <lightning-Card title='Contact Related Cases' icon-name='custom:custom11'>
       
    
        <lightning-datatable
                key-field="id"
                data={data}
                columns={columns}>
        </lightning-datatable>
      
</lightning-card>  
</template>
############################################################################################
import { LightningElement,wire,api } from 'lwc';
import getrelatedcase from '@salesforce/apex/dataTable.getrelatedcase';
const columns = [
{label: 'CaseNumber',fieldName: 'CaseNumber',type: 'text'},
{label: 'Status',fieldName: 'Status',type: 'text'},
{label: 'Priority',fieldName: 'Priority',type: 'text'}
];
export default class Contactrelatedcases extends LightningElement {
    data = [];
    @api recordId;
    columns = columns;
    error;

@wire(getrelatedcase, {
         contactId: '$recordId'
    })
    wiredCases(value){
        this.wiredActivities = value;
        const { data, error } = value;
    
    if(data){
        let dataEditing = JSON.parse(JSON.stringify(data));
        this.data = dataEditing;
        
    }else if(error){
        this.error = error;
    }
    }
}
############################################################################################
public with sharing class dataTable {
    @AuraEnabled(cacheable = true)
    public static List<case> getrelatedcase(string contactId){
        List<case> caseList =[SELECT Id, CaseNumber, Status, Priority FROM Case where ContactId = :contactId];
        return caseList;
    }
}
Please Mark It As Best Asnwer If It Helps
Thank You!