How to run action block from Main Screen
Question
Application Type
Reactive

Hi  ,

I am facing one problem , i want to call block action from main screen but not able to do it.

Is there any way.


Thanks in Advance.

mvp_badge
MVP
Solution

Hi ,

You can go with this document 

How to Call a Block Action in a Mobile Screen - OutSystems 

OR you can try -

1. Create a button on block and bind action

2. Hide this button by css (display:none) and provide a class for this button.

3. From main screen you can use one Button to call this action and use this JS for it-

 var x = document.getElementsByClassName("ButtonClass");

  var i;

  for (i = 0; i < x.length; i++) {

    x[i].click();


  }


Hope this will help you.

Regards

Rahul

Hi,

You can try:

1. Create an input for the block. It can be isTriggered (boolean and default = false).

2. Call block's Action inside OnParameterChanged event of the block.

3. Trigger block's Action by update isTriggered from main screen.


Cheers,

Khuong

Thank you @Rahul Sahu and @Khuong Truong . it helps me.


Hi,

I prefer Khuong's post, it is much easier to maintain in this way, if we use JS to do this, we may pay attention when we try to do a change.

A bit older post but just to add my two cents.. What I use to for e.g. saving blocks contents is a variant on what Khuong suggested: 

  1.  Adding an input parameter to the block called TimeToSave (or any other name reflecting what the parameter should trigger) with Time data type. And another local parameter called e.g. SaveTime. 
  2. Catching the change of this parameter in the OnParametersChanged handler by calling the the blocks action "Save" and set the local parameter SaveTime to the TimeToSave input.  So if you have more input parameters you only want to run the blocks's Save action if the value of TimeToSave changes. Not if another parameter is changing
  3. Then, from the parent I just set the TimeToSave input parameter to CurrTime() to trigger the action..
Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.