Is there something to configure in order to make the navService / lightning:navigation work as expected ?
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 :
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 :
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 initialised 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 :
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
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).