1

I am trying to redirect to a Report in Report Builder from a LWC. However I did not find any substantial information that specifically mentions redirection to "Report" page type , inside the documentation.

This is what I tried:

In Markup :::

<div>
    <a href={reportUrl} onclick={redirectToReport}>View Report</a>
</div>

In JS controller :::

redirectToReport(evt) {
    evt.preventDefault();
    evt.stopPropagation();
    this[NavigationMixin.Navigate](this.reportUrl);
}

connectedCallback() {
    this[NavigationMixin.GenerateUrl]({
        type: 'standard__webPage',
        attributes: {
            url: '/lighting/r/Report/00OR0000000PCHYMA4/view'
        },
    }).then(url => {
        this.reportUrl = url;
    });
}

However I get back this message in console: Target page has no matching URL

I tried passing the hardcoded URL directly to the NavigationMixin but I get back the exact same error.

1 Answer 1

2

As you want to navigate to standard object record page Report, you will not need href attribute. You can directly use Record Page navigation on click. Below is how you can implement:

HTML:

<a onclick={redirectToReport}>View Report</a>

JS:

redirectToReport(evt) {
    evt.preventDefault();
    evt.stopPropagation();
    this[NavigationMixin.Navigate]({
        type: 'standard__recordPage',
        attributes: {
            recordId: '00OR0000000PCHYMA4',
            objectApiName: 'Report',
            actionName: 'view'
        }
    });
}

Just recheck and confirm that 00OR0000000PCHYMA4 is correct report id.

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.