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
Dennis Warner2Dennis Warner2 

Convert a url button to a lightning component.

Hello, I've been working to convert this url button: 
/apex/SDOC__SDCreate1?id={!FX5__Quote__c.Id}&Object=FX5__Quote__c
into a lightning component.  I've already built the component button, but i don't know where to put the above url.  In controller?  How would that look?  I've tried figuring it out on trailhead, but it'll take another week before it answers my question.  Any answers would be appreciated.
 
pradeep kumar yadavpradeep kumar yadav
Hi Dennis,

You can use isUrlAddressable interface to call lightning component and pass parameters to it.
https://developer.salesforce.com/docs/component-library/bundle/lightning:isUrlAddressable/documentation
Dennis Warner2Dennis Warner2
I'm sorry, Pradeep.  What you've sent is something a developer could digest easily i'm sure.  The link you've sent looks like a foreign language to me, however.  
 
pradeep kumar yadavpradeep kumar yadav
Add this interface in your lightning component that you created like
<aura:component implements="lightning:isUrlAddressable">

add this handler in your lighting component

<aura:handler name="change" value="{!v.pageReference}" action="{!c.onPageReferenceChange}"/>

replace url in your button with this url

/lightning/cmp/c__componentName?c__id={!FX5__Quote__c.Id}&c__Object=FX5__Quote__c

Add this method in lightning component controller js---
 
onPageReferenceChange: function(cmp, evt, helper) {
        var myPageRef = cmp.get("v.pageReference");
        var id = myPageRef.state.c__id;
        var objectName = myPageRef.state.c__Object;
        
//Use these variable values in your component
    }

Note:- If the link look like foreign language to you then,who created the lightning component? Ask him to follow the above steps.
 
Sandhya Narayanan 10Sandhya Narayanan 10
Hi Dennis,
Were you able to resolve this issue? I too am trying to create the SDOC link from a lightning component.