You need to sign in to do that
Don't have an account?
![Abdulhannan Patel 8 Abdulhannan Patel 8](https://dfc-org-production.my.site.com/img/userprofile/default_profile_45_v2.png)
recordData not loading the info from the custom lightning action on task page
Hello,
I have one custom lightning action on the task page. I am trying to show a create event page with some events fields prepopulated like WhoId and WhatId from the task. I am using the force:recordData to get the data from task and pass it to the event page. However, the data is not loaded in the targetFields attribute. Can someone help me here?
<aura:component implements="force:appHostable,flexipage:availableForAllPageTypes,force:hasRecordId,force:lightningQuickAction"
access="global" controller="ScheduleEventController" extends="c:Base" description="Create_Follow_up_Event">
<aura:attribute name="simpleRecord" type="Object"/>
<aura:attribute name="recordError" type="String"/>
<force:recordData aura:id="recordLoader1"
recordId="{!v.recordId}"
layoutType="FULL"
targetFields="{!v.simpleRecord}"
recordUpdated="{!c.myAction}" />
<lightning:spinner variant="brand" size="medium" />
<!-- Display Lightning Data Service errors, if any -->
<aura:if isTrue="{!not(empty(v.recordError))}">
<div class="recordError">
<ui:message title="Response" severity="info" closable="true">
{!v.recordError}
</ui:message>
</div>
</aura:if>
</aura:component>
({
myAction : function(component, event, helper) {
//$A.get("e.force:closeQuickAction").fire();
console.log('I am called');
var taskId = component.get("v.recordId");
var contactId = component.get("v.simpleRecord.WhoId");
console.log('taskId>>',taskId);
console.log('simpleRecord>>',component.get("v.simpleRecord"));
}
})
The contactId is null in the client side controller!
Thank you guys.
I have one custom lightning action on the task page. I am trying to show a create event page with some events fields prepopulated like WhoId and WhatId from the task. I am using the force:recordData to get the data from task and pass it to the event page. However, the data is not loaded in the targetFields attribute. Can someone help me here?
<aura:component implements="force:appHostable,flexipage:availableForAllPageTypes,force:hasRecordId,force:lightningQuickAction"
access="global" controller="ScheduleEventController" extends="c:Base" description="Create_Follow_up_Event">
<aura:attribute name="simpleRecord" type="Object"/>
<aura:attribute name="recordError" type="String"/>
<force:recordData aura:id="recordLoader1"
recordId="{!v.recordId}"
layoutType="FULL"
targetFields="{!v.simpleRecord}"
recordUpdated="{!c.myAction}" />
<lightning:spinner variant="brand" size="medium" />
<!-- Display Lightning Data Service errors, if any -->
<aura:if isTrue="{!not(empty(v.recordError))}">
<div class="recordError">
<ui:message title="Response" severity="info" closable="true">
{!v.recordError}
</ui:message>
</div>
</aura:if>
</aura:component>
({
myAction : function(component, event, helper) {
//$A.get("e.force:closeQuickAction").fire();
console.log('I am called');
var taskId = component.get("v.recordId");
var contactId = component.get("v.simpleRecord.WhoId");
console.log('taskId>>',taskId);
console.log('simpleRecord>>',component.get("v.simpleRecord"));
}
})
The contactId is null in the client side controller!
Thank you guys.
Try like below
<aura:component implements="force:appHostable,flexipage:availableForAllPageTypes,force:hasRecordId,force:lightningQuickAction"
access="global" controller="ScheduleEventController" extends="c:Base" description="Create_Follow_up_Event">
<aura:attribute name="simpleRecord" type="Object"/>
<aura:attribute name="recordError" type="String"/>
<force:recordData aura:id="recordLoader1"
recordId="{!v.recordId}"
layoutType="FULL"
targetFields="{!v.simpleRecord}"
fields="Id, Name"
recordUpdated="{!c.myAction}" />
<lightning:spinner variant="brand" size="medium" />
<!-- Display Lightning Data Service errors, if any -->
<aura:if isTrue="{!not(empty(v.recordError))}">
<div class="recordError">
<ui:message title="Response" severity="info" closable="true">
{!v.recordError}
</ui:message>
</div>
</aura:if>
</aura:component>
I tried putting id and whoId in the fields to fetch and console log on the myAction showed Undefined value for the simpleRecord component attribute.
Am I missing something?