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
VJ_SFDCVJ_SFDC 

Can we call lightning component from salesforce formula field

I have a formula field and there I am using this HYPERLINK("/apex/RelatedContentVFPage?Id="+Content_ID__c, 'Test') basically Content_ID__c means i am passing Content document ID.

the code I have written with in the visual force page:
RelatedContentVFPage
 
<apex:page >
    <apex:includeLightning /> <div style="width:600px;height:450px;" id="ChartContainer" />
    <script>
    $Lightning.use("c:LC_RelatedContentApp", function() {
        $Lightning.createComponent("c:LC_PreviewRelatedContent",
                                   {
// Pass params to the lightning component here
                                   },
                                   "ChartContainer",
                                   function(cmp) {
                                       console.log('Component Created');
                                   });
    });
    </script>
</apex:page>
LC_RelatedContentApp
 
<aura:application access="GLOBAL" extends="ltng:outApp">
    <aura:dependency resource="c:LC_PreviewRelatedContent"/>
</aura:application>

LC_PreviewRelatedContent
 
<aura:component  implements="flexipage:availableForAllPageTypes">
    <aura:handler name="init" value="{!this}" action="{!c.goToCohesityAssets}"/>   
    TEst Component
</aura:component>
LC_PreviewRelatedContentController
({
   
    goToCohesityAssets:function(component, event, helper) { 
	$A.get('e.lightning:openFiles').fire({
            recordIds: ["0691g000000CiLJ"]
        });
	},
})

When a user clicks on salesforce formula field in lightning whatever the hard coded content document i placed in the controller I wanted to display that as PDF. It is working directly if i use in salesforce lightning component but it is not working if i call lightning component from visualforce page.
The error I see it now is below.

User-added image