You need to sign in to do that
Don't have an account?

Lightning Component Task.Type Field is Empty
I have a lightning component which calls an Apex method to initiate a Task:
@AuraEnabled public static Task initTask(Id contactId) { Task t = new Task( Type = 'Type A', OwnerId = UserInfo.getUserId(), Status = 'Completed', ActivityDate = Date.today(), Priority = 'Normal', Subject = 'Notes' ); System.debug('t = ' + t); return t; }When I call this, the Type field appears to be empty:
var action = component.get("c.initTask"); action.setParams({ "contactId": contactId }); action.setCallback(this, function(a) { var state = a.getState(); if (state === "SUCCESS") { var record = a.getReturnValue(); console.log("record = "); console.log(record); console.log(record.Type); if(record.Type == '') { console.log('Type is empty'); } else { console.log('Type is something else?'); } console.log(a.getReturnValue().Type) component.set('v.record', record); console.log('post set'); console.log(component.get('v.record').Type); } else if (state === "ERROR") { var errors = a.getError(); console.error(errors); } }); $A.enqueueAction(action);
In the log, console.log(record.Type) shows the expected value, however, if I write out {!v.record.Type} in my component, it's empty.
If I reference a different field, it works as expected; my suspicion is that Type is a reserved attribute/parameter, however, I'm unsure of a clean workaround.
Any insights are appreciated.
https://success.salesforce.com/answers?id=9063A000000pJNeQAM
https://help.salesforce.com/articleView?id=000193640&language=en_US&r=https%3A%2F%2Fwww.google.com%2F&type=1
working sample :
apex :
lightning
output :
kindly let us know if it helps you
thanks