2

How to call different community page from LWC page on button click that exists on a community page without passing the URL?

navigateToWebPage() {
        // Navigate to a URL
        this[NavigationMixin.Navigate]({
            type: 'standard__webPage',
            attributes: {
                url: 'http://salesforce.com'
            }
        },
        {
            // Replaces the current page in your browser history
            // with the URL
            true
        });

Is there any way by which I just pass the community page name and it calls that?

2 Answers 2

2

This worked for me -

this[NavigationMixin.Navigate]({
            type: 'standard__namedPage',
            attributes: {
                pageName: 'becomepartner',
            },
        });
1
0
  • 1st prepare object with api name and other parameters to be send

  • 2nd generate url

  • 3rd launch the page.

    step -1

          this.pageReference = {
             type: 'comm__namedPage',
             attributes: {
                 name: 'SitePageB__c' //api name of community page
             },
             state: {
                 recordId: this.account.id //passing Id to another page to be used further
              },
         };
    

    step 2

     if (this.pageReference) {
             this[NavigationMixin.GenerateUrl](this.pageReference)
                 .then(url => {
                     this.href = url;
                 });
         }
         evt.stopPropagation();
         evt.preventDefault();
    

    step 3

     if (this.pageReference) {
         this[NavigationMixin.Navigate](this.pageReference);
     }
    

You must log in to answer this question.

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