Skip to main content

Hi

i currently have a few list buttons in classic which simply open a VF page and passes a few parameters. i am trying to figure out how to replace these with Lightning but having no luck. Can anyone point me in the right direction?

 

Thanks!

2 comments
  1. Sep 26, 2017, 3:57 PM

    Hi Andrew,

    You could achieve this by creating a lightning component, use it as a quick action, and in the JS Controller you can redirect to a visual force page.

    When you create the component be sure to use

    implements="force:lightningQuickAction,force:hasRecordId"

    So you can use it as a quick action and also you get the record id to do the process.

    Save the record Id in an attribute to manipulate in the component, use:

    <aura:attribute name="recordId" type="String" />

    Also, you can add a handler so when as soon as the component is loaded you execute a function to redirect

    Ex: <aura:handler name="init" value="{!this}" action="c.doInit" />

    And in the JS controller the function is something like

    doInit : function(component, event, helper) {

    var recordId = component.get("v.recordId");

    var url = "/apex/nameOfVFpage?parameter="+recordId;

    window.open(url, '_self');

    }

    In case that you need more parameters to send, you might need a function that get those from the server using the record Id that so far is the only attribute you get from the record in a component.

    In this case you have to add an Apex controller in the component, and the function must include @AuraEnabled tag so those can be called from a JS controller

    Refer here:

    https://developer.salesforce.com/docs/atlas.en-us.lightning.meta/lightning/components_using_lex_s1_config_action_recordid.htm

    Hope this can help you.

0/9000