1

Summary

I work on a SFDX project with one package, and within my aura component, I'm currently having problems with the lightning:navigation element. I followed the docs from Aura Component - Navigation but still my button does not redirect me as expected.

Details & what I've tried

I do have this line in my aura component :

<lightning:button label="Navigate" onclick="{!c.handleClick}"/>

And then, my js controller does the following :

    handleClick: function(cmp, event, helper) {
        event.preventDefault();
        const navService = cmp.find("navService");
        const pageReference = {
            type: 'standard__objectPage',
            attributes: {
                objectApiName: 'Account',
                actionName: 'list'
            },
            state: {
                filterName: "Recent"
            }
        };
        console.log(navService);
        console.log(pageReference);
        navService.navigate(pageReference);
    }

So, when I'm clicking the button in my UI, this is the output of the 2 console.log() above :

console.log() output

But no redirection is done. So when I'm clicking my button that is supposed to redirect me to the page pageReference :

  • My navService is well initialized and has a navigate() function and is logged as shown above
  • My pageReference is logged (see console output above, 2nd item)
  • But the line navService.navigate(pageReference); does nothing (no redirection, no error, no log message.)

So my questions are :

  • Am I missing something ?
  • Is there something to configure in order to make the navService / lightning:navigation work as expected ?
  • Why is there no redirection when I'm following the exact same code as the documentation ?

More specific details (possibly not relevant)

FYI my aura component (.cmp file) does have an implements key like so : <aura:component implements="force:appHostable,flexipage:availableForAllPageTypes"> Also, I don't know if this is relevant but my navigate() function of the navService displays the following elements in my console :

Exception: TypeError: 'caller', 'callee', and 'arguments' properties may not be accessed on strict mode functions or the arguments objects for calls to them at Function.invokeGetter

exception

EDIT :

Also, please note that the Navigate button is embedded into some kind of UtilityBar (flexipage), in the bottom left of the page.

UtilityBar

4
  • 1
    That last error looks like it might be very relevant actually. Have you looked into the error message? Dec 7, 2021 at 14:14
  • @VictorLockwood I looked into the error there and many other places but still I don't know if this error is a problem, and if so, how to solve it. My thought was that this error is raide because developer console can't access to some elements. 'Still searching on this one. Dec 7, 2021 at 15:03
  • 1
    Hm... Other difference I'm seeing is you're using 'const' instead of 'var' (the lightning:navigation examples don't use const). Maybe try switching that out? Dec 7, 2021 at 16:51
  • Yeah. Unfortunately tried the change and does not help. Also please see the updated post, I added some more information about the 'Navigation' button. My team and I are still working on it, but I think we may end up using another system for opening salesforce pages, like lightning tabs. Because this navigation thing is a real issue for us for now. Dec 7, 2021 at 17:18

2 Answers 2

1

There is actually no problem with lightning:navigation, the problem was that my aura component was embedded into an iframe, because I was using a Salesforce Utility Bar. (see last element of my question)

Therefore, if you encounter this problem, just make sure your component is not rendered within an iframe, because it seems that calls to lightning:navigation won't work from there (within the iframe).

1
  • 1
    I've noticed similar trying to test external links in Experience Builder (not using the NavigationMixin) - using a window.open into a new tab would fail due to their security policies since everything in the builder is rendered in an iframe. Testing on the published site, however, would work fine. Dec 23, 2021 at 19:55
0

To anyone coming across this now, please use the functions of opencti for redirection. screenPop or searchAndScreenPop.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .