You need to sign in to do that
Don't have an account?
Jonathan Wolff 7
Error by using Who.Name of tasks in datatable
Hello friends, I have a task datatable component and added the Who.Name as a column. the problem is, that now I do get error messages whenever there is a task where Who.Name is empty. Could you give me a solution for it?
My code:
APEX
JS
My code:
APEX
@AuraEnabled public static List<Task> loadTasks3(Id recordId){ string userId = UserInfo.getUserId(); return[SELECT Subject, Who.Name, ActivityDate, Status FROM Task WHERE ActivityDate = TOMORROW AND OwnerId=:userId AND Status !='Completed']; }
JS
component.set('v.mycolumns', [ {label: 'Thema', fieldName: 'SubjectName', type: 'url', typeAttributes: {label: { fieldName: 'Subject' }, target: '_blank'}}, {label: 'Name', fieldName: 'whoName', type: 'text', typeAttributes: {label: { fieldName: 'Who.Name' }, target: '_blank'}}, ]); var action = component.get("c.loadTasks"); action.setCallback(this, function(response){ var state = response.getState(); if (state === "SUCCESS") { var records =response.getReturnValue(); records.forEach(function(record){ record.SubjectName = '/'+record.Id; record.whoName = record.Who.Name }); component.set("v.tasks", records); } }); $A.enqueueAction(action);
As I can clearly see that you have a parameter named recordId in your apex method (loadTasks) , but you have not included the parameter in your js controller. You can remove a parameter from your apex method, as I can see there is no use of that. You can refer to the below apex method :
Please mark it as the best answer, if it solves your problem
Thanks and Regards
Suraj Tripathi
All Answers
I reviewed your error message that you have shared and I came up with these solutions:
- I found the apex method you shared is named loadTasks3 , but in the js controller you are calling loadTasks .
- You are also not providing parameter to the apex method in your js controller.
Please try these above solutions and if it solves your query , please mark it as the best answer .Thanks and Regards
Suraj Tripathi
Could you elaborate what you mean with providing parameters to js controller?
Greetings,
Jonathan
Could you please provide me the Apex method for 'loadTasks'.
Moreover, If you are passing parameters in apex method, then you also need to set parameters in js controller too.
Thanks and Regards
Suraj Tripathi
As I can clearly see that you have a parameter named recordId in your apex method (loadTasks) , but you have not included the parameter in your js controller. You can remove a parameter from your apex method, as I can see there is no use of that. You can refer to the below apex method :
Please mark it as the best answer, if it solves your problem
Thanks and Regards
Suraj Tripathi