Share lightning attributes with a Skuid page

  • 1
  • Idea
  • Updated 6 months ago
  • (Edited)
Hey! Forgive me if this has already been asked/requested.

When building lightning components you can declare attributes which are filled in by the user when they drag the component into the app builder or community builder. Like this:
<aura:attribute name="title" type="String" default="Title" access="global" />
I was wondering if, when in the same component you declare a Skuid page, you could somehow pass in those attributes and use them in the Skuid page (e.g. via merge syntax).

Like this (but you'd need to somehow pass in multiple attributes):
<aura:component implements="forceCommunity:availableForAllPageTypes" access="global" >
    <aura:attribute name="title" type="String" default="Title" access="global" />

    <skuid:page STUFFTOPASS={!v.title} page="Lovely_Skuid_Page"/>

</aura:component>
y' dig?

Cheers!

Louis
Photo of Louis Skelton

Louis Skelton

  • 4,878 Points 4k badge 2x thumb

Posted 10 months ago

  • 1
Photo of Louis Skelton

Louis Skelton

  • 4,878 Points 4k badge 2x thumb
Thinking about it, there might be a way of doing this already using the event stuff... Hmm....
Photo of Zach McElrath

Zach McElrath, Employee

  • 49,056 Points 20k badge 2x thumb
There is a way to do what you're looking for with the parameters attribute, which accepts a JSON string of parameters to pass in to the underlying Skuid page. Each key in the JSON object will become a Page Parameter available within the Skuid Page.

<aura:component implements="flexipage:availableForAllPageTypes" access="global" >
    <skuid:page page="OrderList" parameters='{"foo":"bar"}'/>
</aura:component>

Unfortunately, there's not much you can do with these parameters within Skuid at present. We're working to resolve this for the Millau Update 1 release, which is coming out in mid-February.
Photo of Louis Skelton

Louis Skelton

  • 4,878 Points 4k badge 2x thumb
Hey Zach, did this ever make its way into the release? I'm trying to think of the easiest way of passing the record id to a Skuid page embedded in a lightning component (in a Community). I can pass the id by publishing an event but was wondering if I could just pass it as a parameter as above, and if so, how would I reference that parameter in the page?

Cheers!

Louis
Photo of Louis Skelton

Louis Skelton

  • 4,878 Points 4k badge 2x thumb
Oh wow! I think this is working fine? Human error yesterday. Nice! So this is a great way to pass the recordId into a Skuid page from within a Lightning Component!

Cheers!
Photo of Louis Skelton

Louis Skelton

  • 4,878 Points 4k badge 2x thumb
Here's how it works, for anyone who's interested. Create a component like this (implementing whatever else you need to get it to work where you want it to):

<aura:component implements="force:hasRecordId">
    <aura:attribute name="skuidParams" type="String" />
    <aura:handler name="init" value="{!this}" action="{!c.doInit}"/>
    
    <skuid:page page="YOUR_SKUID_PAGE" parameters="{!v.skuidParams}"/>
</aura:component>

And add this to your lightning controller:

({
    doInit: function (cmp, event, helper) {
        
        // Get the record Id
        var recordId = cmp.get('v.recordId');
        
        // Set params in an object
        var params = {
            "id": recordId
        }
        
        // Convert object to JSON
        params = JSON.stringify(params);
        
        // Set those params in an attribute on the component
cmp.set("v.skuidParams", params);
    }
})
Photo of Mark DeSimone

Mark DeSimone, Official Rep

  • 11,050 Points 10k badge 2x thumb
Louis, thank you for continuing to update this thread as you've worked on this. It's definitely relevant as more customers are working towards moving to Lightning. I'm glad Zach was able to offer a good response in January, and I'm going to bring this to our documentation team as a topic that warrants further exploration.