Is it possible to set publishing scope on calls to skuid.events.publish(event, data) ?

edited April 11, 2020 in Questions

Hello I would like to publish an event to send data from a skuid aggregate model to a lightning component.

skuid.events.publish('AggMessage', JSON.stringify(payload));

AggMessage is never making it to the component listing on 

<aura:handler event="skuid:event" action="{!c.handleSkuidEvent}"/>

I'm assuming this is because the publishing scope of AggMessage needs to be set to "All active pages and Lightning Components"  How do I set event scope from code?

Thanks,
Peter




Comments

  • edited October 9, 2018
    Here's another alternative/related question.

    I made the event below with the builder with publish to Lightning Components scope and my component is receiving it. How do I add data payload to this event?

    <action type="publish" scope="global" event="UpdateAggriate">
                                <params/>
    </action>

    Thanks,
    Peter
  • edited May 17, 2018
    You can add Parameters by clicking the "+" icon on the Publish Event action. This lets you provide key-value pairs of data that is sent to the Lightning Component as an object.
  • edited June 19, 2018
    The "Publish Event" action type in the Action Framework is the highly recommended way to set the publishing scope to "All active Skuid Pages and Lightning Components". Technically yes it is possible to specify the scope via the JavaScript API but we'd like to avoid customers using that unless for some reason using the declarative "Publish Event" action is not working.
  • edited May 18, 2018
    Fantastic!   When I click on the disk icon to select a field to use as a value doesn't popup anything?   I'm not sure what syntax I should use for the </> button.   How do I add a field from an aggregate model?
  • edited October 9, 2018
    OK, I'm hopeful!   Thanks! Peter
  • edited May 18, 2018
    If you want to pull in a Model field as a value, you can use {{{$Model.YourModelName.data.0.The_Field_You_Want__c}}}
  • edited May 18, 2018
    It worked!   Thank you so much!
  • edited June 19, 2018
    Hi Zach... I'm having to trigger an event from an html submit button in a Skuid template component which the Lightning component can listen for.

    My current approach is to listen for an event locally on the Skuid page (skuid.events.publish('some.event')) and to then use an event-triggered sequence in Skuid to listen to this and then publish another event via the action-framework to the surrounding Lightning Component using the broader scope.

    This is working fine but it'd be nice to know how to publish to the broader scope straight from javascript rather than using the above two-step process. Any chance you could spill the beans on this?

    Just a note - I also found that you had to set the even-triggered sequence to "All Active Pages and Lightning Components" for the above listener to work - even though the javascript was publishing the event from a snippet in the same Skuid page.
  • edited June 19, 2018
    An alternative approach would be to be able to trigger an event-triggered sequence from within a snippet/javascript
  • edited June 19, 2018
    I'll go ahead and post the way to set publishing scope to "All Skuid Pages and Lightning Components" via JavaScript:
    skuid.events.publish("AggMessage", [payload], { scope: skuid.constants.EVENT_SCOPES.GLOBAL });
  • edited June 19, 2018
    Thank you!!!! :)
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!