1

I am trying to navigate to the Order Summary Detail standard page in a B2B LWR experience site, however the page needs the recordId of the Order Summary in order to be able to show the data. How can I pass the recordId in Navigation Mixin?

enter image description here

This currently doesnt work:

this[NavigationMixin.Navigate]( {
            type: 'comm__namedPage',
            attributes: {
                name: 'Order_Summary'
            },state: {
                recordId: ordSumId 
            }
        });

I also tried this other approach, but it doesnt seem right to do it generating the url with the id, plus I have issues testing it in experience builder. Any ideas? I couldnot find anything specific in the documentation about how to navigate to experience site pages that require params such as recordId

this[NavigationMixin.GenerateUrl]({
             type: 'standard__webPage',
             attributes: {
                 url: path + '/' + ordSumId
           }
         }).then(url=> {window.open(url,"_self");});

Thanks a lot!

1 Answer 1

0

You need to have a api enabled property on your LWC, which will allow you to use the {!recordId} expression in the builder, passing the value into your component for use:

getRecordId.js

import { api, LightningElement } from "lwc";

export default class GetRecordId extends LightningElement {
    @api ordSumId;

    onclick(event) {
        this[NavigationMixin.Navigate]({
            type: 'comm__namedPage',
            attributes: {
                name: 'Order_Summary'
            },
            state: {
                recordId: this.ordSumId 
            }
        });
    }
}

Don't forget this before referencing the variable name or you'll get an error when the component runs

getRecordId.js-meta.xml

<?xml version="1.0" encoding="UTF-8"?>
<LightningComponentBundle xmlns="http://soap.sforce.com/2006/04/metadata">
    <apiVersion>57.0</apiVersion>
    <isExposed>true</isExposed>
    <masterLabel>Get Record Id</masterLabel>
    <targets>
        <target>lightningCommunity__Page</target>
        <target>lightningCommunity__Default</target>
    </targets>
    <targetConfigs>
        <targetConfig targets="lightningCommunity__Default">
            <property label="Order Summary ID" name="orderSumId" type="String" required="true" default="{!recordId}" />
        </targetConfig>
    </targetConfigs>
</LightningComponentBundle>

You must log in to answer this question.

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