+ Start a Discussion
Jacob Elliott 8Jacob Elliott 8 

LWC- Sort Records Returned By Wire Service To Be Used By Child Components

Hello All, I'm trying to create a parent component that uses wire service to grab task records and then sorts them into two maps(?) to be consumed by child components. I need them sorted by Status = Completed or Status != Completed.

I'm having trouble figuring out how to iterate over the returned records.

Any help would be greatly appreciated!

public with sharing class ATLController {
    public static List<Task> getTasks(String recordId) {
        return [SELECT Id, Subject, TaskSubtype, ActivityDate FROM Task WHERE WhatId = :recordId];
import { LightningElement, api, wire } from 'lwc';

export default class AtlBase extends LightningElement {
    @api recordId;

    completedTaskList = [];
    upcomingTaskList = [];

    @wire(getTasks, {recordId:'$recordId'}) 

        for(let task in tasks){
            if(task.Status === 'Completed'){
            } else if(task.Status != 'Completed'){

Best Answer chosen by Jacob Elliott 8
Check this - https://www.infallibletechie.com/2020/03/how-to-iterate-over-records-returned-by.html