0

My requirement is to build a lightning-flow to create customer. While the flow ends, it should be opening another tab of newly created customer (I'm using console view). I tried the following LWC to allow users to have a button to click and navigate to the record page of the newly created customer.

HTML:

<template>
   <div class="slds-var-p-around_small slds-align_absolute-center">
      <p>The newly created record Id is {newRecordId}</p>
      <lightning-button variant="brand" label="Finish and redirect me" onclick={handleClick}></lightning-button>
   </div>
</template>

Javascript:

@api newRecordId;
url;

connectedcallback() {
   this.newRecordPageRef = {
      type: 'standard__objectPage',
      attributes: {
         recordId: this.newRecordId,
         objectApiName: 'Customer__c',
         actionName: 'view'
      }
   };
   this[NavigationMixin.GenerateUrl](this.newRecordPageRef)
      .then(url => this.url = url);
}

handleClick(event) {
   event.preventDefault();
   event.stopPropagation();
   this[Navigation.Navigate](this.newRecordPageRef);
}

Nothings happen while I click the "Finish" button inside the flow. I tried to put the lwc on an app page and the button is working. I'm referencing this https://developer.salesforce.com/docs/component-library/documentation/en/lwc/lwc.use_navigate_basic

Please help.

0

After some google-ing I found that I made a very stupid mistake. The type of the page should be standard__recordPage instead of standard_objectPage. After changing it, I'm able to redirect at the end of the flow.

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.