I built a quick action on Campaign that opens a lightning component. I am trying to pass parameters like, say the Id and the name of the Campaign.

Earlier I built this using Detail Page Button and executing javascript like so:


Is it possible to somehow retrieve those values from the component that gets triggered from the quick action?

Please note, I have no Visual Force page and am not planning on building one.

If this doesn't work can I use a button that opens a lightning App and pass the parameters as a query string then retrieve them somehow from the component?

EDIT I found that I can add implements="force:hasRecordId" to the component and that will give me the object's Id. Is it possible to pass the name similarly without having to query for the record?


As you've discovered, you can get force:hasRecordId. Unfortunately, any other fields you want, you have to query for. The easiest way to query for them is with force:recordData; this automatically pulls the data from the cache, when available, and includes the record's name:

<aura:component implements="force:hasRecordId,force:lightningQuickAction">
  <aura:attribute name="record" type="Campaign" />
    recordUpdated="{!c.recordLoaded}" />

From here, you will have access to the fields you've requested:

    recordLoaded: function(component, event, helper) {
        var campaign = component.get("v.record");
        // Do whatever you need here

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.