Accessing payload of Component event

I feel like there’s something missing in my understanding of component events.

I have a card, made into a component. On a button click there’s an event being triggered.
The event has a workflow “on_event” on the parent outside the component. This is all fine.

What I was trying to achieve is the following.
OnClick, before sending the event, I want the component do to some work and send a payload with the event (using event value).

I don’t seem to get where I can access that payload within the event workflow ??

1 Like

Great question!

Could you give more details on the part you mentioned- the component do to some work and send a payload with the event (using event value)?

It looks like you’re familiar with the basics but have you had a chance to review this article or the video about triggering component events?

Yes thank you. I watched all those articles and videos and it doesn’t cover the event payload. Just the event triggering.

But I did figure out how it works. I had to use the console log to catch the payload and understand the structure in order to catch and cast it properly on the event “triggered” side of things.

The problem is that you can’t see what the payload is live during execution. Since you can’t put a debug breakpoint in workflows, you can never catch the “event triggered” and look at what’s happening.

As you can see here, the ‘Event’ is always undefined.
Also, for the ‘event’ variable to appear in the bottom browser, you have to execute your event trigger at least once.

You need to define the event (trigger schema) in the settings. The events are usually not available like this , because the event has’t happened yet. So I think you might just want to log the empty event and attempt to trigger it in order to see the payload.

Exactly what I thought. Thanks for the input.
How do you define an event schema ? Can’t find anything on it in the doc.

Trigger schema, when you’re creating the trigger.

Yes, I know where it is, I don’t know what should be put in there !? JSON, Javascript, variables …
Do you have a Event schema exemple ?

Thanks.

I found that the Event value doesn’t overwrite the default Event Schema. It seems that we cannot pass a payload based on a variable, just don’t know exactly if it is a current limitation or a bug.

The workaround I found for this is by updating a component variable that can be accessed by outside.

You’re overcomplicating it and using not standard. Schema is just informative, it’s a helper to give you a hint of the data structure, the result once the action is run is the real data.

But that’s my point, the workflow execution always returns the schema instead of the Event value I passed when triggering it.


Hi @EduardoChaves

Have you checked this article: Component events | WeWeb Documentation

As mentioned by Broberto, the event is only informative. The binding UI is just an informative template. If you log the event value, you will see the correct results.

Hi @danlopes I just tested it and the event value returns the proper value from the trigger.

My complainants were because I thought the value would be the default event schema that was showing on my workflow, instead of the actual value returned from the trigger.

I think it would be great if the event data could dynamically update as the developer uses it, just like the proper workflow history that we may visualize the variables value used in the execution.