1

I have a reasonably simple method that is called from a button on my lightning component. The controller method then calls a Salesforce method to grab the URL of a page. I need to do this as the URL is generated by a webservice (we contact another system to generate the URL).

What I've found is that on certain versions of Safari, specifically with popups not enabled, the urlEvent.fire(); fails and doesn't open the generated URL. I've also found that this appears to occur only when the 'fire' method is called as part of a callback. It works perfectly when we go straight to a URL.

Here is an example of the problem:

goToScanViewer : function(component, event, helper){        

    var generateLinkAction = component.get("c.getScanImagesURL");
    generateLinkAction.setParams({ accessionNumber : component.get("v.accessionNo")});

    generateLinkAction.setCallback(this, function(response) {
        var state = response.getState();
        if (component.isValid() && state === "SUCCESS") {
            var urlEvent = $A.get("e.force:navigateToURL");
            urlEvent.setParams({
                "url": response.getReturnValue(),
                "isredirect" :false
            });
            urlEvent.fire();
        }
        else {
            console.log("Failed with state: " + state);
        }
    });    

    // Send action off to be executed
    $A.enqueueAction(generateLinkAction);
}

-

<ui:button label="Button" press="{!c.goToScanViewer}" class="slds-button slds-button--brand"/>

It's worth noting that using 'location.href' works perfectly but I'd like to try to stick to Salesforce/Aura framework as closely as possible as over the last few months it's clear that this is what Salesforce want's us to do (locker service, etc).

  • This isredirect should be set to true. right? – Rohit Mourya Mar 23 '17 at 11:33
  • Hi @RohitMourya it doesn't work with true or false unfortunately. I may be incorrect but I think the 'isredirect' parameter only relates to whether or not the event is put into the browser navigation history. – William Smith Mar 23 '17 at 11:37

Your Answer

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

Browse other questions tagged or ask your own question.