Tag:

isUrlAddressable

    Call Lightning Component using Formula Link

    Call Lightning Component using Formula Link

    Many time we have use case where we need to call Lightning Component from record’s detail page. To accomplish this requirement we can use formula field which will create hyperlink. This feature is introduced in Summer 18 and it can call aura component using lightning:isUrlAddressable.

    Let us see this complete feature implementation. Below are steps for this

    1. Create hyperlink using formula field
    2. Create Lighting component to read parameter’s value
    1. Create hyperlink using formula field

      Create a formula field on Account to launch Lightning Component and read its parameter. We have to put c__ before every parameter otherwise it will not be available in Lightning component.  Similar to highlighted portion in below image.

    2. Create Lighting component to read parameter values

      Let us create component ViewFile which read parameter’s values. We have to implement interface lightning:isUrlAddressable to read parameter.

      ViewFile.cmp

         
      <aura:component implements="flexipage:availableForRecordHome,force:lightningQuickAction,force:hasRecordId,force:hasSObjectName,lightning:isUrlAddressable" access="global" controller="SupportingDocumentViewFileController">
         <aura:attribute name="recordId" type="String" access="global" />
      <aura:handler name="init" value="{!this}" action="{!c.doInit}"/>
      </aura:component>
      

      ViewFileController.js

         
      ({
          doInit : function(component, event, helper){
              var pageReference = component.get("v.pageReference");
              if(pageReference!==undefined && pageReference!==null && pageReference.state!=null)
              {
                  var recordId=pageReference.state.c__recordId; 
                  component.set("v.recordId",recordId);
                  //Do whatever we want to do with record id 
              }
              }
      })
      

     

    May 28, 2019 1 comment
    1 Facebook Twitter Google + Pinterest