I have a requirement to display a data table for open and closed activities based on on some criteria that is from a managed packaged. The challenge was that you can not access the open and closed activity tables directly but need to do it with a subquery. I am trying to flatten out the data in Apex before I return it to the client so it can be displayed in a lightning:datatable. But I keep getting a value of [object object] in my my console log. I am hoping a better JS dev can tell me what I am missing here. I have tried to use JSON.Parse and JSON.Stringify but no luck.

Here is my controller

    public static List<OpenActivityWrapper> getOpenActivities(String groupId){
        List<String> resultList = new List<String>();
        Set<Id> accountIds = getAccountIds(groupId);
        List<BA_EIMA_activityController.OpenActivityWrapper> openActivityWrappers = new List<BA_EIMA_activityController.OpenActivityWrapper>();

        List<Account> openActivities = [SELECT Id, Name,
        (SELECT ActivityDate, Account.Name, Account.Id, Subject, IsTask, WhatId, Description, EndDateTime,
        Status, Priority, APX_Assigned_To_Name__c, APX_Assigned_To_User__c
        from OpenActivities) FROM Account where Id =: accountIds];

        for (Account a : openActivities ){
            for(OpenActivity activity : a.openActivities){
                BA_EIMA_activityController.OpenActivityWrapper wrapper = new BA_EIMA_activityController.OpenActivityWrapper(
                        a.Id, a.Name, activity.Subject, activity.Status, activity.IsTask, activity.EndDateTime
        System.debug('value in wrapper = ' + openActivityWrappers);
        System.debug('value from result list = ' + resultList);
        return openActivityWrappers;
     public class OpenActivityWrapper{
        Id  accountId;
        String accountName;
        String subject;
        String activityStatus;
        Boolean isTask;
        Datetime closeDate;

        public OpenActivityWrapper(String accountId, String accountName, String subject, String activityStatus,
                Boolean isTask, Datetime closeDate){
            this.accountId = accountId; this.accountName = accountName; this.subject = subject;
            this.isTask = isTask; this.activityStatus = activityStatus; this.closeDate = closeDate;

JS file

import {LightningElement, track, wire, api} from 'lwc';
import getOpenActivities from '@salesforce/apex/BA_EIMA_activityController.getOpenActivities';

export default class BaEimaOpenRelationshopGroupActiviities extends LightningElement {

    @track accounts;
    @track error;
    @api recordId;   

    @wire(getOpenActivities, {groupId: '$recordId'})
    activities({error, data}) {
        if (data) {
            this.accounts = data;
            console.log(`value of accounts = ${JSON.stringify(this.accounts)}`);
            this.error = undefined;
        } else if (error) {
            this.error = error;
            this.accounts = undefined;


    <lightning-card title="Open Activities">        
        <template if:true={accounts} for:each={accounts} for:item="account">
            <li key={account.Id}>

The return in the debug log looks like

2:49:15:052 USER_DEBUG [31]|DEBUG|value in wrapper = (OpenActivityWrapper:[accountId=0013C00000Bkh6EQAR, accountName=EIMA TEST HK1, activityStatus=Not Started, closeDate=null, isTask=true, subject=Follow-up], OpenActivityWrapper:[accountId=0013C00000C4PFBQA3, accountName=EIMA TEST HK 2, activityStatus=Not Started, closeDate=null, isTask=true, subject=Call])
  • 1
    Did you try - console.log('value of account'+JSON.stringify(this.accounts)); without the back ticks. Dec 31, 2019 at 18:36

1 Answer 1


The issue is in your wrapper class. Each variable in your wrapper should be annotated with AuraEnabled to be displayed back in the UI.

public class OpenActivityWrapper{

        public Id  accountId { get; set; }
        public String accountName { get; set; }
        public String subject { get; set; }
        public String activityStatus { get; set; }
        public Boolean isTask { get; set; }
        public Datetime closeDate { get; set; }

Have a look at LWC recipe for how to pass complex Apex Datatype to and fro from apex to JS: https://github.com/trailheadapps/lwc-recipes/blob/master/force-app/main/default/classes/CustomWrapper.cls

  • 1
    Thank you Pranjay. Something so simple and I never would have thought of it. I thought only the method needed to be annotated. Worked like a charm. Dec 31, 2019 at 19:15

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.