function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
sfuser12sfuser12 

How to add cutom link in lightning component?

Hi,

I want to add custom link in lightning component instead of custom link or button.

Can any one tell how to add it in lightning component

Custom Link: https://dfsco--sync.lightning.force.com/lightning/r/Report/00O1b000000VDEfEAO/view?fv0={!Campaign.Id}

Thanks,
sfuser12
 
Best Answer chosen by sfuser12
sfuser12sfuser12
Hi,

I have done something like this and it it working in lightning component.

Lightning Component
<aura:component implements="force:appHostable,flexipage:availableForAllPageTypes,flexipage:availableForRecordHome,force:hasRecordId,forceCommunity:availableForAllPageTypes,force:lightningQuickAction" access="global" >
    <aura:attribute name="recordId" type="String"/>
    <aura:attribute name="myRecordID" type="String" default="ID hasn't been set yet!"/>
    <aura:handler name="init" value="{!this}" action="{!c.doInit}"/>
    
    <a href="{!'https://dfsco--sync.lightning.force.com/lightning/r/Report/00O1b000000VDEfEAO/view?fv0=' + v.myRecordID}"
       target="_new">View All Campaign Members</a> <br/>
    <a href="{!'https://dfsco--sync.lightning.force.com/lightning/r/Report/00O1b000000VDAnEAO/view?fv0=' + v.myRecordID}"
       target="_new">View Campaign Influence Report</a>
</aura:component>

Controller
({
    doInit : function(cmp) {
        cmp.set("v.myRecordID",cmp.get("v.recordId"));
    }
})

00O1b000000VDAnEAO and 00O1b000000VDEfEAO will be your custom report ids.

All Answers

Khan AnasKhan Anas (Salesforce Developers) 
Hi,

Greetings to you!

Please refer to the below links which might help you further with the above requirement.

https://success.salesforce.com/answers?id=9063A000000pHDwQAM

https://salesforce.stackexchange.com/questions/156289/custom-links-to-generate-dynamic-reports-in-lightning

https://releasenotes.docs.salesforce.com/en-us/spring17/release-notes/rn_rd_reports_filter_url.htm

I hope it helps you.

Kindly let me know if it helps you and close your query by marking it as solved so that it can help others in the future. It will help to keep this community clean.

Thanks and Regards,
Khan Anas
sfuser12sfuser12
Hello Khan Anas,

I have created custom link and it is working too. My headache is adding it into lightning component as a link.

Thanks,
sfuser12
 
sfuser12sfuser12
Hi,

I have done something like this and it it working in lightning component.

Lightning Component
<aura:component implements="force:appHostable,flexipage:availableForAllPageTypes,flexipage:availableForRecordHome,force:hasRecordId,forceCommunity:availableForAllPageTypes,force:lightningQuickAction" access="global" >
    <aura:attribute name="recordId" type="String"/>
    <aura:attribute name="myRecordID" type="String" default="ID hasn't been set yet!"/>
    <aura:handler name="init" value="{!this}" action="{!c.doInit}"/>
    
    <a href="{!'https://dfsco--sync.lightning.force.com/lightning/r/Report/00O1b000000VDEfEAO/view?fv0=' + v.myRecordID}"
       target="_new">View All Campaign Members</a> <br/>
    <a href="{!'https://dfsco--sync.lightning.force.com/lightning/r/Report/00O1b000000VDAnEAO/view?fv0=' + v.myRecordID}"
       target="_new">View Campaign Influence Report</a>
</aura:component>

Controller
({
    doInit : function(cmp) {
        cmp.set("v.myRecordID",cmp.get("v.recordId"));
    }
})

00O1b000000VDAnEAO and 00O1b000000VDEfEAO will be your custom report ids.
This was selected as the best answer
Gary RalstonGary Ralston
Hi sfuser12,

Here's a complete example of how to create a custom link in a Lightning Component by using LWC:
Create a New Lightning Web Component:

customLinkExample.html
<template>
    <div>
        <p>Click the custom link:</p>
         //Replace "https://www.example.com" with your desired custom link URL
        <a href="https://www.example.com" target="_blank" onclick={handleLinkClick}>Custom Link Text</a>
    </div>
</template>

customLinkExample.js
import { LightningElement } from 'lwc';

export default class CustomLinkExample extends LightningElement {
    // Function to handle the custom link click event
    handleLinkClick() {
        // Add your custom logic here (e.g., show a message)
        alert('Custom link clicked!');
    }
}
Furthermore, if you are in search of a comprehensive guide on creating custom links in Salesforce Classic, I recommend visiting the website https://arrify.com/custom-links-in-salesforce-classic/. This guide provides step-by-step instructions for creating custom links in Salesforce Classic while following to best practices.