You need to sign in to do that
Don't have an account?
Peter Martensen 8
I need help with a Lightning Component button that redirects to the previous page
I need a Lightning Component button in my Community that will redirect to the previous URL. I have a preview button that opens a pdf, and I need an easy way for the user to get to the record page. I created the button and it shows up in my Community. I found this code online that is supposed to redirect to the previous URL. It isn't working. Can someone tell me how to change it so it will take me back to the previous page?
Thanks
Thanks
({ redirect: function (){ var url = window.location.href; var value = url.substr(0,url.lastIndexOf('/') + 1); window.history.back(); return false; } })
https://developer.salesforce.com/docs/component-library/bundle/lightning:navigation/documentation
Note: once developed please test the component placing in a lightning page as this doesn't work on the lightning app