2

Does anyone have thoughts as to why force:navigateTo[n] events appear to fire twice in the following scenario?

I have a lightning component exposed as a lightning tab inside Salesforce1. At one point in the app workflow, a link is displayed for an Account. When the user taps this link, it should open the Account record in Salesforce1 like normal, with the back navigation option to return to the previous screen.

The recipe for this action is provided by the Lightning docs here for the force:navigateToSObject component , and I have followed them exactly:

var navEvt = $A.get("e.force:navigateToSObject");
var recordId = cmp.get("v.account.Id");
navEvt.setParams({
    "recordId": recordId,
    "slideDevName": "detail"
});
navEvt.fire();

When I tested in the Salesforce1 Simulator, it seemed to work fine, but when I tested in the Salesforce1 app, it attempted to open the record in an unauthenticated temporary browser window. If I tapped "done" it would close the browser, return to the Salesforce1 app, and display the Account record. I could then return to my lightning component as expected.

I tried using the force:navigateToURL method and received the same results.

Upon closer inspection of my initial test with the simulator, I noticed I had to click the back button twice to actually return to the lightning component, which suggests the issue actually occurs in the simulator, but because it is an authenticated web browser, it doesn't present the same UI issue as when performed in the app.

Here's the code from my component:

<aura:component implements="force:appHostable">
    <ui:outputURL aura:id="theAccountLink" value="#" label="Record" click="{!c.toggleModal}"></ui:outputURL>
</aura:component>

And the code from my controller:

({
    toggleModal : function(cmp, event, helper) {
        var navEvt = $A.get("e.force:navigateToSObject");
        navEvt.setParams({
            "recordId": '001K0000015M4Jl', 
            "slideDevName": "detail"
        });
        navEvt.fire();
    }
})

If I stick to a URL without a click event, I get correct UI behavior, but SF1 attempts to open the record in a different org. So if I'm in a sandbox, the following will attempt to open the record in the production org:

<ui:outputURL aura:id="theAccountLink" value="/001K0000015M4Jl" label="Record"></ui:outputURL>

Further testing has revealed a difference between iOS and Android.

  • Double Redirect Behavior = Salesforce1, Version 10.0.1, Build 3026989 on iOS 9.3.2 (13F69)
  • Correct Behavior = Salesforce1, Version 10.0, Build 647 on Android 6.0.1
  • I tried to reproduce your issue, but it works fine in Android SF1.Can you share the relevant component and controller code to debug the issue? – Praveen Jul 18 '16 at 20:16
  • I just tested with an android device and experienced the same double redirect behavior. – Isaac Jul 18 '16 at 22:47
  • @Issac have you tried adding / in the value of the <ui:outputURL />.Look at this answer – Praveen Jul 19 '16 at 16:32
  • @Praveen, I saw that just after I posted, and tried it, but it produces the same results of navigating to the production org. – Isaac Jul 19 '16 at 16:33
  • @Issac I tried to this code <ui:outputURL aura:id="theAccountLink" value="#" label="{!v.account.Name}" click="{!c.openUrl}"></ui:outputURL> code in my org and navigating through e.force:navigateToSObject it works for me.I couldn't reproduce your issue. Tested in Android SF1 – Praveen Jul 19 '16 at 16:35

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.