How can I read a task object properties in a lightning controller. Because var a=component.get("v.Task").Status; returns error which is Uncaught

Error in $A.getCallback() [Cannot read property 'Status' of null].

Can anyone tells me if the Task object is supported by Lightning UI? Thank you this is my .cmp

<aura:component controller="JSMUserInfoService" implements="force:lightningQuickActionWithoutHeader,force:hasRecordId" access="global">
  <aura:attribute name="user" type="JSMUserInfo" />
    <div style="height: 6rem;">
        <div role="status" class="slds-spinner slds-spinner_large slds-spinner_brand">
            <span class="slds-assistive-text">Loading</span>
            <div class="slds-spinner__dot-a"></div>
            <div class="slds-spinner__dot-b"></div>
    <aura:attribute name="recordId" type="Id" />
    <aura:attribute name="Task" type="Object"/>
    <force:recordData aura:id="recordLoader"


And this is my controller:

  doInit : function(component, event, helper) {
    var getProfileInfo = component.get("c.getProfileInfo"); 

     getProfileInfo.setCallback(this, function(response) {
          var state = response.getState();
      if(state == "SUCCESS" && component.isValid()){
          var result = response.getReturnValue();
          var a=component.get("v.Task").Status;
        if(a!= "Ouvert" ||( result.Name != "System Administrator" && result.Name != "Administrateur système")){
        } else {
          var CreateTask = component.get('c.CreateTask'); 
          CreateTask.setCallback(this, function(response){
          var state = response.getState(); // get the response state
          if(state == 'SUCCESS') {
            var res = response.getReturnValue();
            res.Id = component.get("v.Task").Id;
            var getUserInfo = component.get('c.getUserInfo'); 
            getUserInfo.setCallback(this, function(response){
              var state = response.getState();
              if(state == 'SUCCESS') {
                var info = response.getReturnValue();
                res.OwnerId = info.Id;
                var updateTask = component.get('c.updateTask');
                  "task" : res
                updateTask.setCallback(this, function(response){
                  var state = response.getState();
                  if(state == 'SUCCESS') {

  • 1
    Please edit your question to add more context. There are specific Lightning components that do not support Task. – David Reed Jun 26 '19 at 11:28
  • I edited my post, thank you David Reed – SF trainer Jun 26 '19 at 13:15

<force:recordData> does not support Task and Event.

The documentation on the component refers us to the UI API documentation for a list of supported objects. That list is here. Task and Event aren't listed and are unsupported.

This is in common with other base Lightning components, like <lightning:recordViewForm>, where it's explicitly stated that

This component doesn't support all Salesforce standard objects. For example, the Event and Task objects are not supported.

You'll have to use Apex to access these records, unfortunately.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.