249
Views
5
Comments
Solved
Changing input parameter of Block in response to an event
Application Type
Mobile, Reactive

I'm a total OutSystems beginner. I've written a Block that wraps a JS library in a Library Module, and use it in an app Screen.

The Block has input parameters which I use for configuration. The Block also emits an Event, which the screen handles in a Client Action.

What I'm struggling with is probably very simple but I just can't figure it out from the documentation: how can I reference the Block, which is part of the Screen's widget tree, in the Client Action? When the Event occurs, I would like to update an input parameter on the Block (setting an 'enabled' input parameter to false while the user makes some decision, and setting it back to true when the user wants to continue). I've tried using an 'Assign' statement in the Client Action but the Block does not show up in the dropdown for the lefthand side of the assignment.


2024-03-18 10-31-07
Alex Suzuki
Solution

I think I figured it out... at least one way of doing it...

1) Added a new local variable 'enabled' to the screen.

2) Connected Block's input parameter 'enabled' to the new local variable

3) Update local variable in Screen's Client Action

Not sure if that's the proper way of doing things (feels a bit redundant), but it seems to work.

2024-05-22 06-12-56
Vignesh Prakash

Hi @Alex Suzuki

If feasible please share the OML or relevant screenshots to understand better.

Thanks,
Vignesh Prakash.

2024-03-18 10-31-07
Alex Suzuki

1) Screen contains a Block named 'BarcodeReaderBlock', event is handled in 'BarcodeDetected' Client Action.


2) BarcodeDetected Client Action displays a value from event, here I want to toggle the 'enabled' property of the Block, but don't know how to reference the Block.

Thanks for any advice/helpful pointers.

2024-08-22 11-39-17
Pedro Sousa

Hello @Alex Suzuki ,


If I understood correctly, maybe you should pass the enabled as an input of the block and make some logic in the On Parameters Changed of the web block.

Training about On Parameters Changed 

https://learn.outsystems.com/training/journeys/blocks-and-events-635/on-parameters-changed/o11/82


Hope this helps :)

Regards,

Pedro

2024-03-18 10-31-07
Alex Suzuki

Hi Pedro

The block already implements OnParametersChanged... it runs some JavaScript that calls through to the wrapped JS library.

What I don't understand is how can I set the 'enabled' input parameter in the Client Action? I know how to set it in the Block's configuration, but I would like to change it at runtime.


2024-03-18 10-31-07
Alex Suzuki
Solution

I think I figured it out... at least one way of doing it...

1) Added a new local variable 'enabled' to the screen.

2) Connected Block's input parameter 'enabled' to the new local variable

3) Update local variable in Screen's Client Action

Not sure if that's the proper way of doing things (feels a bit redundant), but it seems to work.

Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.