Close Menu
SalesforceCodex
    Facebook X (Twitter) Instagram
    Trending
    • The Ultimate Guide to Data Cleanup Techniques for Salesforce
    • How to Leverage Model Context Protocol (MCP) to Enhance Salesforce AI
    • Top Mistakes Developers Make in Salesforce Apex Triggers
    • Introducing Agentforce3 to Salesforce Developers
    • The Ultimate Guide to Apex Order of Execution for Developers
    • How to Handle Bulkification in Apex with Real-World Use Cases
    • How to Confidently Manage Transactions in Salesforce Apex
    • Building a Dynamic Tree Grid in Lightning Web Component
    Facebook X (Twitter) Instagram
    SalesforceCodex
    Subscribe
    Saturday, August 2
    • Home
    • Salesforce Platform
      • Architecture
      • Apex
      • Lightning Web Components
      • Integration
      • Flows & Automation
      • Best Practices
      • Questions
      • News
      • Books Testimonial
    • Industries
      • Artificial Intelligence
    • Hire Me
    • Certification
      • How to Prepare for Salesforce Integration Architect Exam
      • Certification Coupons
    • Downloads
      • Salesforce Release Notes
      • Apex Coding Guidelines
    • About Us
      • Privacy Policy
    • Contact Us
    SalesforceCodex
    Home»Salesforce»Call Lightning Component using Formula Link

    Call Lightning Component using Formula Link

    Dhanik Lal SahniBy Dhanik Lal SahniMay 28, 2019Updated:May 7, 20207 Comments1 Min Read
    Facebook Twitter Pinterest LinkedIn Tumblr Email
    Call Lightning Component using Formula Link
    Share
    Facebook Twitter LinkedIn Pinterest Email

    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">
         <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 
              }
              }
      })
      

     

    formula field isUrlAddressable salesforce
    Share. Facebook Twitter Pinterest LinkedIn Tumblr Email
    Previous ArticleSend Email Using Email Template and Apex
    Next Article Zoom-able Image in Lightning Component
    Dhanik Lal Sahni
    • Website

    Related Posts

    By Dhanik Lal Sahni6 Mins Read

    How to Leverage Model Context Protocol (MCP) to Enhance Salesforce AI

    July 28, 2025
    By Dhanik Lal Sahni7 Mins Read

    Top Mistakes Developers Make in Salesforce Apex Triggers

    July 25, 2025
    By Dhanik Lal Sahni14 Mins Read

    The Ultimate Guide to Apex Order of Execution for Developers

    July 20, 2025
    View 7 Comments

    7 Comments

    1. Kishan on May 30, 2019 9:41 am

      Nice information.

      Reply
    2. Rajneesh Raj on February 5, 2020 2:42 pm

      This is not working for me. I did the same as it is mentioned in the blog but it is not working.

      Reply
      • Dhanik Lal Sahni on February 5, 2020 3:40 pm

        Hello Rajneesh, Can you share your code here or at salesforcecodex@gmail.com to check issue? We can join on Zoom as well to resolve your issue.

        Thank You,
        Dhanik

        Reply
    3. xyz on May 7, 2020 7:40 pm

      SupportingDocumentViewFileController reffered in missing

      Reply
      • Dhanik Lal Sahni on May 7, 2020 9:40 pm

        Hello Ansh,

        You can remove controller from component. It is not required for this use case.

        Thank You,
        Dhanik Sahni
        https://salesforcecodex.com/

        Reply
    4. Richard on July 16, 2021 9:00 am

      Hi Dhanik, thank you, I’ve been looking for a way to pass the record Id from URL to a lightning component or page. Your post is closest to the solution that I can find, but for some reason the lightning component I created still did not use the record Id.

      Reply
      • Dhanik Lal Sahni on July 16, 2021 8:22 pm

        Hello Richard?
        Are you getting record id in aura or not? If not, are you using in community?

        Thank You,
        Dhanik

        Reply
    Leave A Reply Cancel Reply

    Ranked #1 Salesforce Developer Blog by SalesforceBen.com
    SFBenTopDeveloper
    Ranked #4 Salesforce Developer Blog by ApexHours.com
    ApexHoursTopDevelopers
    Categories
    Archives
    Tags
    apex (116) apex best practices (5) apex code best practice (10) apex code optimization (6) Apex logging (4) apex rest (11) apex trigger best practices (6) architecture (22) Asynchronous apex (9) AWS (5) batch apex (10) best code practice (4) code optimization (9) custom metadata types (5) design principle (9) flow (16) google (6) google api (4) integration (19) integration architecture (6) lighting (8) lightning (66) lightning-combobox (5) lightning-datatable (10) lightning component (32) Lightning web component (64) lwc (53) named credential (8) news (4) optimize apex (5) optimize apex code (6) optimize apex trigger (5) Permission set (4) Queueable (9) queueable apex (4) rest api (23) salesforce (150) salesforce apex (52) salesforce api integration (5) Salesforce Interview Question (5) salesforce news (5) salesforce question (5) solid (6) tooling api (5) Winter 20 (8)

    Get our newsletter

    Want the latest from our blog straight to your inbox? Chucks us your detail and get mail when new post is published.
    * indicates required

    MailChimp

    Expert Salesforce Developer and Architect
    Ranked #1 SALESFORCE DEVELOPER BLOG BY SALESFORCEBEN.COM
    Featured on Top Salesforce Developer Blog By ApexHours
    Recent Posts
    • The Ultimate Guide to Data Cleanup Techniques for Salesforce
    • How to Leverage Model Context Protocol (MCP) to Enhance Salesforce AI
    • Top Mistakes Developers Make in Salesforce Apex Triggers
    • Introducing Agentforce3 to Salesforce Developers
    • The Ultimate Guide to Apex Order of Execution for Developers
    Ranked in Top Salesforce Blog by feedspot.com
    RSS Recent Stories
    • Top 10 Salesforce CRM Trends to Watch in 2025 July 18, 2025
    • Discover the Top 10 Salesforce AppExchange Apps to Boost Productivity July 10, 2025
    • Top 20 Salesforce Data Cloud Interview Questions & Answers for Admins June 5, 2025
    • How to Connect Excel to Salesforce to Manage Your Data and Metadata February 9, 2025
    • Difference Between With Security and Without Security in Apex January 2, 2025
    Archives
    Categories
    Tags
    apex (116) apex best practices (5) apex code best practice (10) apex code optimization (6) Apex logging (4) apex rest (11) apex trigger best practices (6) architecture (22) Asynchronous apex (9) AWS (5) batch apex (10) best code practice (4) code optimization (9) custom metadata types (5) design principle (9) flow (16) google (6) google api (4) integration (19) integration architecture (6) lighting (8) lightning (66) lightning-combobox (5) lightning-datatable (10) lightning component (32) Lightning web component (64) lwc (53) named credential (8) news (4) optimize apex (5) optimize apex code (6) optimize apex trigger (5) Permission set (4) Queueable (9) queueable apex (4) rest api (23) salesforce (150) salesforce apex (52) salesforce api integration (5) Salesforce Interview Question (5) salesforce news (5) salesforce question (5) solid (6) tooling api (5) Winter 20 (8)

    Get our newsletter

    Want the latest from our blog straight to your inbox? Chucks us your detail and get mail when new post is published.
    * indicates required

    Facebook X (Twitter) Instagram Pinterest YouTube Tumblr LinkedIn Reddit Telegram
    © 2025 SalesforceCodex.com. Designed by Vagmine Cloud Solution.

    Type above and press Enter to search. Press Esc to cancel.

    Ad Blocker Enabled!
    Ad Blocker Enabled!
    Our website is made possible by displaying online advertisements to our visitors. Please support us by disabling your Ad Blocker.