You need to sign in to do that
Don't have an account?
Jonathan Wolff 7
Hello, I have build a task datatable component and added the Who.Name as a column. It is working fine when the Who.Name field has content in it, otherwise I get an error message when leaving the field empty. Could you give me a solution for it?
My code:
APEX
JS
Problem when having Who.Name field in datatable and record with empty field
Hello, I have build a task datatable component and added the Who.Name as a column. It is working fine when the Who.Name field has content in it, otherwise I get an error message when leaving the field empty. Could you give me a solution for it?
My code:
APEX
//ÜBERFÄLLIG - Abfrage Tasks, wo das Activity Date abgelaufen und der Status "Not Completed" ist// @AuraEnabled public static List<Task> loadTasks(Id recordId){ string userId = UserInfo.getUserId(); return[SELECT Subject, Who.Name, WhoId, ActivityDate, Status FROM Task WHERE ActivityDate< TODAY 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);
Please try the below update:
record.whoName = (record.WhoId != '' && record.WhoId != null) ? record.Who.Name : '';
Thanks,
Maharajan.C
All Answers
Please update your code line with
if you need any assistanse, Please let me know!!
Kindly mark my solution as the best answer if it helps you.
Thanks
Mukesh
Please try the below update:
record.whoName = (record.WhoId != '' && record.WhoId != null) ? record.Who.Name : '';
Thanks,
Maharajan.C
"Action.prototype.finishAction Error [Error in $A.getCallback() [Cannot set properties of undefined (setting 'Name')]
Callback failed: apex://TaskController/ACTION$loadTasks]"
What can I do about it?
Thanks,
Maharajan.C
Greetings and thank you :)
Do you want the name should be displayed in the lead name hover instead of Id? I don't think it's simple you have to think and work... there is no need of name in the url hover because already we are displaying the name in the table column ... Do you have any other issue to discuss... Otherwise please close this threat by choosing the best answer...
For me the table looks like below:
Thanks,
Maharajan.C