0

My whole community is developed with lightning components,I want to stay on the same page if the page refreshes, and also to easily go to different pages with the query string.

Ex. I have component A on home page (which contains data table) so on click of drop down menu of data table i am opening new component in new tab but in lightning community that component not getting open and error is coming saying "URL no longer exists". But this same URL is working fine if i wont use it through community. i am new to community please guide me.

var urlEvent = $A.get("e.force:navigateToURL");
var url = 'https://test-developer- 
edition.na71.force.com/PartnerRKC/s/lightning/cmp/c__avTest';
urlEvent.setParams({"url": url});
urlEvent.fire();

Here 'https://test-developer-edition.na71.force.com/PartnerRKC' is my community URL while 'c__avTest' is component i am opening with navigateToURL event.

and i am using '/c__avTest' as URL only in lightning component and it is redirecting me to avTest component As it was not working for community i have added 'https://test-developer-edition.na71.force.com/PartnerRKC' in url to redirect to component but not working for me in community.

  • Please add code to the question on how you are trying to implement the navigation – RedDevil Jan 9 at 7:24
  • @RedDevil Hey just look into the question i have updated it. – Chintal Somaiya Jan 9 at 7:27
1

Create a Lightning Page inside community and include your lightning component into it. Then try navigateToURL event. Ex : Your lightning community page name is - Details

   var urlEvent = $A.get("e.force:navigateToURL");
    urlEvent.setParams({
        "url": "/Details",
        "isredirect": false
    });
    urlEvent.fire();
  • I also wanted to pass some parameters along with component as avTest component wont execute without passing isTested= true and all kinda paramters @Pavanaja – Chintal Somaiya Jan 9 at 10:14
  • "url": "/Details?isTested=true" - pass it in this way. @ChintalSomaiya – Pavanaja Y Jan 9 at 10:18
  • Hey thanx.....yeah finally i am able to open component with your example but i am not getting value of parameters in avTestController.js i have passed in URL. In doinit of avTest i am using "component.get("v.pageReference");" to get values of parameters i have passed(avTest is component i have added in detail page) – Chintal Somaiya Jan 10 at 4:39
  • you need to read current page url using javascript code in your init method. Split based the paramaters. 'window.location.href' - this will read your current page url and split it based on your need. @ChintalSomaiya – Pavanaja Y Jan 10 at 5:27
  • 1
    Yeah i think this might work - create a design attribute and include {!isTested} in the value of design attribute while configuring it in the builder. Create a aura attribute with the same name of the design attribute & try to read the value in the init method. Let me know if this works or not. – Pavanaja Y Jan 10 at 7:04

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.