I have AuraEnabled method in a following class:

public with sharing class HistoryRecordsHandler {
public static List<HistoryRecordWrapper> getAccountAndContactHistoryRecords(Id accId) {
    List<HistoryRecordWrapper> hrws = new List<HistoryRecordWrapper>();

    List<AccountHistory> accHis = [SELECT AccountId, CreatedById, CreatedDate, Field, DataType, IsDeleted, NewValue, OldValue FROM AccountHistory WHERE AccountId = :accId];
    List<ContactHistory> conHis = [
        SELECT ContactId, CreatedById, CreatedDate, Field, DataType, IsDeleted, NewValue, OldValue
        FROM ContactHistory
        WHERE Contact.AccountId = :accId

    for (ContactHistory conHi : conHis) {
        HistoryRecordWrapper crs = new HistoryRecordWrapper(conHi);

    for (AccountHistory accHi : accHis) {
        HistoryRecordWrapper hrs = new HistoryRecordWrapper(accHi);

    return hrws;

Once I call the method from the LWC component I am getting internal server error: b {status: 500, body: Error: An internal server error has occurred}

import { LightningElement, track } from 'lwc';
import getHistoryRecords from '@salesforce/apex/HistoryRecordsHandler.getAccountAndContactHistoryRecords';
connectedCallback() {
        .then((listOfHistoryRecords) => {
            this.historyRecords = listOfHistoryRecords;
        .catch((error) => console.log('error happening: ', error));


Am I missing something in the class?? When I execute this method in the developer console I am getting the correct response (account and contact history records)

1 Answer 1


Your parameters need to be named, even if you only have one:


This is a problem with your JavaScript, not your class.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .