On my community page(A) I have a LWC component with a button which onclick will call an apex method to create a record. If the create is successfull it needs to redirect to another community page(B). Onclick calls the method handleConfirm. The issue I am facing is though the record is created/saved succesffully in the backend, the system doesn't redirect to the community page B. It remains on community page A. Through debug, I confirmed the code under the handleConfrim .then does get executed but nothing happens.
Below is the code snippet.

connectedCallback() {
    this.prod = something;
    .then(result => {
        // does something in a for loop to populate some options.
        error => {
            this.error = error;
    .finally(() => this.showflag = true );

    createSubscription({aId: this.asstPgm.Id,
    ep:this.prgm, uId: this.userId})
        this.isSuccess = true;
            type: 'comm__namedPage',
    .catch(error =>{
        this.error = error;

What I am doing wrong here? Any suggestions on how I could fix this issue.

  • LWC Developer guide states that the attribute property for name community pages is name and not pageName (Although, I've not tested it, I've seen some blogs stating that the usage of pageName works). Can you try with name attribute property? – arut Nov 19 '20 at 18:14
  • The navigation attributes are correct as it works fine in other functions without the imperative call. I have a doubt, the imperative call and the connectedCallback is messing with the flow, but can not figure issue out. – SFDCresh Nov 19 '20 at 20:08
  • Can you place some console.log statements insider the then & catch blocks to trace the execution flow? Also, why do you think connectedCallback would interfere here? It executes during the component rendering lifecycle (not necessarily during every event handling in the component). – arut Nov 20 '20 at 3:40

enter image description here

Import NavigationMixin and Apply the NavigationMixin to the component's base class.

  • Thanks, that's already been done and is part of the code. – SFDCresh Nov 19 '20 at 17:57
  • is the community page name is correct please check once? – H R Nov 19 '20 at 18:18

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.