2

Is there any way to direct read the param from the community URL.

For example I have a custom page with URL like https://abc.com/s/testing?testingAttribute=abc and I want to get the passed testingAttribute attribute and pass the same to the flow added in that community page.

Using lightning:isUrlAddressable I can set the value : var pageReference = { type: 'type to do', attributes: { componentName: 'c__helloTarget', }, state: { "c__firstname": "John" } }; component.set("v.pageReference", pageReference);

and get the same in other component like `var myPageRef = cmp.get("v.pageReference");

However when i am trying to access the values directly Its not working.On the JS side I am using like this :

({
    init : function (component) {

        // Find the component whose aura:id is "flowId"
        var flow = component.find("flowId");
        // In that component, start your flow. Reference the flow's Unique Name.
        flow.startFlow("flowname");
       console.log(component.get("v.pageReference").state.testAttribute);

    },

Getting the below error on running : A cookie associated with a cross-site resource at https://2o7.net/ was set without the SameSite attribute. A future release of Chrome will only deliver cookies with cross-site requests if they are set with SameSite=None and Secure. You can review cookies in developer tools under Application>Storage>Cookies and see more details at https://www.chromestatus.com/feature/5088147346030592 and https://www.chromestatus.com/feature/5633521622188032.

1 Answer 1

2

You can use design time attributes to bind the query string parameters to your component. Define these in your component's .design file.

<design:component>
    <design:attribute name="myAttribute" default="{!myAttribute}" description="Automatically bind the url parameter to the component variable" />
</design:component>

You will need a corresponding attribute in your component's .cmp file.

<aura:component implements="forceCommunity:availableForAllPageTypes">
    <aura:attribute name="myAttribute" type="String" access="global" />

    {!v.myAttribute}
</aura:component>

Important: You must remove and re-add your component onto the community page, then publish the site for new attributes to take effects.

2
  • Need to have attribute marked as global
    – AvengerSF
    Commented Mar 19, 2020 at 1:45
  • Thanks @sdfc-neta. Have updated the answer with the global modifier.
    – akiradev
    Commented Mar 19, 2020 at 9:28

You must log in to answer this question.

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