How to call a webblock after a button is clicked from a different web block
Question
Application Type
Reactive

Hi Team,

I have a case where, I have a webblock-1 which needs to be called when a submit button from an another webblock-2 is clicked. Both the blocks are fetched to a screen and screen has another containers too. When the submit button is clicked and that webblock-1 appears then all the other containers and webblock-2 should be hidden.

mvp_badge
MVP
Solution


Hi Aditya,

In addition to the previous explanation by Ozan, refer to the attached .oml file

See this sample screen: BlockEventMechanism

Pseudo Steps:

  • On Block2 Submit button click
  • Invoke the Block2 Event (HideOtherBlocks Event) -> notifying the parent screen
  • Within the Event Handler Flow defined in the parent screen scope, set the display/show container boolean local variable (hideBlock2) to False


I hope this helps you!


Kind regards,

Benjith Sam

RWALabBlockEvt.oml

Hi Aditya,

Can you give more details about your business requirement? Do you need to pass a parameter to webblock-1 when the submit button in webblock-2 is clicked?

Nevertheless, you can define a boolean local variable "ShowWebBlock" on screen level, False by default, and make it True when Submit is clicked. Then, on the Display property of the containers, you use this local variable. 

To change a screen-level variable, you can create an event in webblock-1 and in the submit click action, you trigger this event and pass the new value you desire for ShowWebBlock (True) to the event as a parameter. And then in the screen where you use webblock-1, you 'handle' the event by creating a Handler_xxx action and in that action, you assign the value coming from the event (True) to the ShowWebBlock variable of your screen. I suggest you take a look at events in web blocks


To use the ShowWebBlock local variable:

For the Display property of the container enclosing webblock-1, you would put ShowWebBlock and for all the other containers that you want to hide, you would put not ShowWebBlock

Or if you don't want your page to render the webblocks at all (instead of just hiding them), you can put the webblocks in an If condition and use that local variable in the If instead of in the Display property.

According to your use case, you can improve the logic that assigns True/False to the local variable, or use more local variables.

Hi Ozan,

I understood your point. But in my case. I have a screen where web-1 and web-2 both are called. Now, when web-2 submit button is clicked. I want to show only the web-1 and hide all others.

Hi Aditya,

You're right, I updated my answer accordingly. Is it helpful now?

Hi Ozan. I tried it this way. But not working. can u plz share oml or images?

mvp_badge
MVP
Solution


Hi Aditya,

In addition to the previous explanation by Ozan, refer to the attached .oml file

See this sample screen: BlockEventMechanism

Pseudo Steps:

  • On Block2 Submit button click
  • Invoke the Block2 Event (HideOtherBlocks Event) -> notifying the parent screen
  • Within the Event Handler Flow defined in the parent screen scope, set the display/show container boolean local variable (hideBlock2) to False


I hope this helps you!


Kind regards,

Benjith Sam

RWALabBlockEvt.oml

Yes got it. Thanks Benjith.

Also thanks to Ozan

mvp_badge
MVP

You're welcome, Aditya

Glad to help you :)


Kind regards,

Benjith Sam

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