Skip to main content
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!

Controller

public with sharing class ATLController {

@AuraEnabled(Cacheable=true)

public static List<Task> getTasks(String recordId) {

return [SELECT Id, Subject, TaskSubtype, ActivityDate FROM Task WHERE WhatId = :recordId];

}

}

JS

import { LightningElement, api, wire } from 'lwc';

export default class AtlBase extends LightningElement {

@api recordId;

completedTaskList = [];

upcomingTaskList = [];

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

tasks;

for(let task in tasks){

if(task.Status === 'Completed'){

completedTaskList.push(task);

} else if(task.Status != 'Completed'){

upcomingTaskList.push(task);

}

}

}

 
1 respuesta
0/9000