0

I want to navigate two urls one after another using lightning component code,I am in Lightning Experience,I want to go Classic printable view page

My tried code:

Component:

<aura:component implements="force:appHostable,flexipage:availableForAllPageTypes,flexipage:availableForRecordHome,force:hasRecordId,forceCommunity:availableForAllPageTypes,force:lightningQuickAction" access="global" >
<aura:attribute name="recordId" type="String" />

     <div>
        <div>
            <lightning:button label="Print" onclick="{!c.navigate}" class="print-hide" />

        </div>

    </div>  
</aura:component>

Controller:

({
navigate : function(component, event, helper) {
}
})

Helper:

({
navigate : function(component, event, helper) {

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

   var urlEvent = $A.get("e.force:navigateToURL");
    urlEvent.setParams({
      "url":'https://domainname/ltng/switcher?destination=classic'
    });
    urlEvent.fire();
    urlEvent.setParams({
      "url":'https://domainname'+printoption+'/p?retURL=/'+printoption
    });
    urlEvent.fire();

}
})

How to Navigate two urls at the same time one after another using lightning component code?

  • hm, do you want to open two new pages simultaneously ? – Oleksandr Berehovskyi Apr 6 '18 at 6:40
  • @AlexanderBerehovskiy,one new page only ,first classic url redirecting that page and after that classic printable view page,not two pages, only one new page – Vinoth Balasubramaniyan Apr 6 '18 at 6:41
  • @AlexanderBerehovskiy ,is it possible or not? – Vinoth Balasubramaniyan Apr 6 '18 at 7:00
1

Yes.OfCourse. It is possible with the for loop.Here is my test code.

Cmp:

<aura:component implements="force:appHostable,flexipage:availableForRecordHome,force:hasRecordId,forceCommunity:availableForAllPageTypes,force:lightningQuickAction" access="global" >
    <lightning:button label="press" type="brand" onclick="{!c.doInit}"/> 
</aura:component>

Controller:

({
    doInit : function(component, event, helper) {
        var list = ['https://www.google.co.in/','https://www.gmail.com'];
        for(var i=0;i<list.length;i++){
            console.log(list[i])
            var urlEvent = $A.get("e.force:navigateToURL");
            urlEvent.setParams({
                "url":list[i]
            });
            urlEvent.fire();
        }
    }
})

Just replace the list with your URL's. It's works Fine.

  • ,no it is not working – Vinoth Balasubramaniyan Apr 9 '18 at 6:28
  • ,if i click the button, it will open google.com page and after that navigate popup is occuring in lightining page,if we click it is openining in another new page,both the urls have to open in single page – Vinoth Balasubramaniyan Apr 9 '18 at 8:30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.