Skip to main content
Hello everyone,

now we are moving from classic to lighting I need to convert all the javascript button to lighting.

We have a custom button which has below url on it

window.open('/apex/vfpagename?id=xxxxx'); 

how to replace window.open(vfpage url?id='xxxx') on custom button in lighting custom button

how do I replace window.open  in lighting and I want the button to work both in lighting and in classic.

Can any please help me on this if any sample code will be appreciated.

Thank you,

Aruna.

 
3 réponses
  1. 15 janv. 2019, 16:46
    Solution :-

    Create a global action and call below lighting component.

    Lighting Component

    <aura:component controller="ProductInUseCntrl2" Implements="flexipage:availableForAllPageTypes,force:lightningQuickAction,force:hasRecordId" access="global" >

     <!--<lightning:button label="Open in new Window" onclick="{!c.openActionWindow}"/>-->

        

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

    </aura:component>

    Java script controller

    ({

        openActionWindow : function(component, event, helper) {

            

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

            window.open( "/apex/vfpageName?id=" + component.get("v.recordId"));

            //window.close();

          $A.get("e.force:closeQuickAction").fire();

        }

    })

    The only problem with this is unable to close the global action window

    Solution :-Create a global action and call below lighting component.

    can anyone, please correct me my code to close quick action window.