0

Basically i'm create a component with zero visual components, just a quickaction button click and a redirect. But i need current record field data.

And can i access the field data in the JS handler without using an apex call?

<aura:component implements="force:lightningQuickActionWithoutHeader,flexipage:availableForAllPageTypes,force:hasRecordId" >
    <aura:handler name="init" value="{!this}" action="{!c.newTicket}"/>
    <force:recordData aura:id="recordLoader"
      recordId="{!v.recordId}"
      targetFields="{!v.simpleRecord}"
      targetError="{!v.recordError}"
      recordUpdated="{!c.handleRecordUpdated}"
      />
</aura:component>

Would that work or since the force:recordData loads asynchronously does it not actually get to load because the init? Could i get the record to load and then fire the init and thus the JS method, that way i can use field data values to create a URL for a redirect?

Or do i have to do an apex call like

handleRecordUpdated : function(c, e, h) {

        var action = c.get("c.getOppList"); 

        action.setParams({

            "oppid": c.get("v.recordId")                     

        });


@AuraEnabled
public static Opportunity getOppList(String oppid) {

 Opportunity opp = [Select Id, AccountId FROM Opportunity Where Id =: oppid limit 1];

I just need the data of the record the quickAction (which started the component) is on, so i can use field values in a URL redirect. How would i do that, is it possible to let force:recordData to run and then execute the init?

1 Answer 1

0

In handleRecordUpdated, you'll have access to the data loaded in simpleRecord; instead of handling an aura:valueInit, you'll wait until the Lightning Data Service (LDS) returns a record. In practice, this should be nearly instant, since the Quick Action would be triggered from a Record Page, so LDS will already have a copy of the record in the local cache.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .