2

I am having a simple redirection from lwc to aura component. In LWC Js:

    this[NavigationMixin.Navigate]({
        type: "standard__component",
        attributes: {
            componentName: "c__OrderLinesUiFullPage"
        },
        state: {
            c__orderId: "test"
        }
    });

And the aura component:

<aura:component implements="flexipage:availableForAllPageTypes,lightning:isUrlAddressable" access="global" >
    <aura:attribute type="String" name="orderId"/>
    Hello {!v.orderId}
</aura:component>

The redirection works fine. But the attribute - the orderId - is not passed successfully. I have followed the instructions provided by document to add c__ before the attribute name but it still doesn't work. Any thoughts?

1 Answer 1

4

You need to add this in your aura component:-

({
    init: function(cmp, evt, helper) {
        var myPageRef = cmp.get("v.pageReference");
        var firstname = myPageRef.state.c__orderId;
        cmp.set("v.orderId", firstname);
    }
})

The attribute value is getting passed, but it needs to be set. Use init handler in your aura component markup.

<aura:handler name="init" value="{!this}" action="{!c.init}"/>    
<aura:attribute type="String" name="orderId"/>
        Hello {!v.orderId}

enter image description here

1
  • Wonderful help!
    – karan
    Dec 28, 2022 at 9:14

You must log in to answer this question.

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