You need to sign in to do that
Don't have an account?
Jonathan Wolff 7
Apex code to show tomorrows day and day after tomorrow
Hi, I build an Component and Controller to show the tasks of specific days. I tried it with the code below but it doesn't display the tasks of tomorrow (loadTasks3) and the day after tomorrow (loadTasks4)
Could you help me with this issue
Greetings
Jonathan
public with sharing class TaskController {
@AuraEnabled
public static List<Task> loadTasks(Id recordId){
string userId = UserInfo.getUserId();
return[SELECT Subject, ActivityDate FROM Task WHERE WhatId=:recordId And ActivityDate< TODAY
AND OwnerId=:userId AND Status !='Completed' ];
}
@AuraEnabled
public static List<Task> loadTasks2(Id recordId){
string userId = UserInfo.getUserId();
return[SELECT Subject, ActivityDate FROM Task WHERE WhatId=:recordId And ActivityDate>= TODAY
AND ActivityDate < Next_N_Days:1 AND OwnerId=:userId ];
}
@AuraEnabled
public static List<Task> loadTasks3(Id recordId){
string userId = UserInfo.getUserId();
return[SELECT Subject, ActivityDate FROM Task WHERE WhatId=:recordId And ActivityDate>= Next_N_Days:1
AND ActivityDate < Next_N_Days:2 AND OwnerId=:userId ];
}
@AuraEnabled
public static List<Task> loadTasks4(Id recordId){
string userId = UserInfo.getUserId();
return[SELECT Subject, ActivityDate FROM Task WHERE WhatId=:recordId And ActivityDate>= Next_N_Days:2
AND ActivityDate < Next_N_Days:3 AND OwnerId=:userId ];
}
@AuraEnabled
public static Task saveTask(Task task){
upsert task;
return task;
}
}
Could you help me with this issue
Greetings
Jonathan
public with sharing class TaskController {
@AuraEnabled
public static List<Task> loadTasks(Id recordId){
string userId = UserInfo.getUserId();
return[SELECT Subject, ActivityDate FROM Task WHERE WhatId=:recordId And ActivityDate< TODAY
AND OwnerId=:userId AND Status !='Completed' ];
}
@AuraEnabled
public static List<Task> loadTasks2(Id recordId){
string userId = UserInfo.getUserId();
return[SELECT Subject, ActivityDate FROM Task WHERE WhatId=:recordId And ActivityDate>= TODAY
AND ActivityDate < Next_N_Days:1 AND OwnerId=:userId ];
}
@AuraEnabled
public static List<Task> loadTasks3(Id recordId){
string userId = UserInfo.getUserId();
return[SELECT Subject, ActivityDate FROM Task WHERE WhatId=:recordId And ActivityDate>= Next_N_Days:1
AND ActivityDate < Next_N_Days:2 AND OwnerId=:userId ];
}
@AuraEnabled
public static List<Task> loadTasks4(Id recordId){
string userId = UserInfo.getUserId();
return[SELECT Subject, ActivityDate FROM Task WHERE WhatId=:recordId And ActivityDate>= Next_N_Days:2
AND ActivityDate < Next_N_Days:3 AND OwnerId=:userId ];
}
@AuraEnabled
public static Task saveTask(Task task){
upsert task;
return task;
}
}
find the below solution
Please mark it as the best answer if it helps you to fix the issue.
Thank you