You need to sign in to do that
Don't have an account?
Jonathan Wolff 7
Change the Task Component to show the tasks of today and the next 7 days
Hi,
I want to build or change the existing Todays-Tasks-Component so it shows the tasks of today and the following 7 days. I dont want the users to have to make clicks to see these tasks. Can you give me a guide to achive it?
Greetings
Jonathan
I want to build or change the existing Todays-Tasks-Component so it shows the tasks of today and the following 7 days. I dont want the users to have to make clicks to see these tasks. Can you give me a guide to achive it?
Greetings
Jonathan
EDIT: made changes in the controller snippet
Let me know if it helps you and close your query by marking it as solved so that it can help others in the future.
Thanks.
All Answers
>> https://salesforce.stackexchange.com/questions/157762/custom-task-lightning-component-not-working
The above link has an implementation of building a custom task component, you can check this and modify it accordingly.
For SOQL you can try this SELECT Subject, ActivityDate FROM Task WHERE WhatId=:recordId And ActivityDate>= TODAY AND ActivityDate <= Next_N_Days:7
Let me know if it helps you and close your query by marking it as solved so that it can help others in the future.
Thanks.
It would be nice if you could help me on it.
Thank you for your good help :D
I think you can make use of lightning:card around the buttons and input values so that there is a white background, for how to use you can try checking the below link:
>> https://developer.salesforce.com/docs/component-library/bundle/lightning:card/example
Let me know if it helps you and close your query by marking it as solved so that it can help others in the future.
Thanks.
Greetings
Component:
<aura:component controller="TaskController" implements="force:appHostable,flexipage:availableForAllPageTypes,force:hasRecordId" >
<aura:attribute name="recordId" type="Id" />
<aura:attribute name="newTask" type="Task" default="{'sobjectType':'Task'}"/>
<aura:attribute name="tasks" type="Task[]"/>
<aura:handler name="init" action="{!c.doInit}" value="{!this}"/>
<ui:inputText aura:id="taskSubject" label="Task Subject" value="{!v.newTask.Subject}"/>
<ui:inputDateTime aura:id="taskDate" label="Activity Date" value="{!v.newTask.ActivityDate}" displayDatePicker="true"/>
<ui:button label="Add Task" press="{!c.createNewTask}"/>
<aura:iteration items="{!v.tasks}" var="item">
{!item.Subject}, {!item.ActivityDate}<br/>
</aura:iteration>
</aura:component>
Controller:
({
doInit: function(component, event, helper) {
var action = component.get("c.loadTasks");
var whatId = component.get("v.recordId");
action.setParams({
"recordId":whatId
});
action.setCallback(this,function(response){
var state = response.getState();
if(component.isValid() && state === "SUCCESS"){
component.set("v.tasks",response.getReturnValue());
}
else{
console.log("Failed with state "+state);
}
});
$A.enqueueAction(action);
component.set("v.newTask.WhatId",component.get("v.recordId"));
},
createNewTask : function(component, event, helper) {
var action = component.get("c.saveTask");
var newTask = component.get("v.newTask");
action.setParams({
"task": newTask
});
action.setCallback(this,function(response){
var state = response.getState();
if(component.isValid() && state === "SUCCESS"){
var items = component.get("v.tasks");
items.push(response.getReturnValue());
component.set("v.tasks",items);
}
else{
console.log("Failed with state "+state);
}
});
$A.enqueueAction(action);
}
})
APEX:
public with sharing class TaskController {
@AuraEnabled
public static List<Task> loadTasks(Id recordId){
return[SELECT Subject, ActivityDate FROM Task WHERE WhatId=:recordId And ActivityDate>= TODAY AND ActivityDate <= Next_N_Days:7];
}
@AuraEnabled
public static Task saveTask(Task task){
upsert task;
return task;
}
}
reference: https://www.sfdckid.com/2019/08/salesforce-lightning-component-to-display-contacts.html
Let me know if it helps you and close your query by marking it as solved so that it can help others in the future.
Thanks.
The above link has an implementation of adding hyperlink to the records so as to redirect to the respective page you can try checking the red part on the snippet and modify it to fit your need.
Let me know if it helps you and close your query by marking it as solved so that it can help others in the future.
Thanks.
EDIT: made changes in the controller snippet
Let me know if it helps you and close your query by marking it as solved so that it can help others in the future.
Thanks.
Thanks.