How to call client action from JavaScript???
Question

Greetings

I have a client action whom I want to call from js is it possible in "reactive web app" ??

Thanks in advance:) 


Does this post from another Community Member help you?

You also have this article in the Call a Client Action section.

How to call a client action inside JavaScript file from Scripts folder. There we don't have reference to any client action.

Found the solution. 

1) We can not direct add Client action call as callback inside global JavaScript (from Script folder) . To do that you have to add the JS file inside screen ( In OnInitialize or OnReady action ) and to handle those function through a button you have to add a container and use its ids to add event handler function as shown below.  


2) From inside the Javascript widget you can call client actions.

mvp_badge
MVP

Hi Anand,

Yes that is possible through the $actions predefined object. More information can be found in this article.

Call a Client Action

Client actions are available through the "$actions" predefined object. This object contains references to:

  • Global client actions defined in the current module or referenced from other modules
  • Other client actions belonging to the same screen/block, if the JavaScript element is placed in a screen/block client action flow

The return value is a simple JavaScript object containing each client action output parameters.

To call a (synchronous) client action that has an output parameter named "Out1", follow the example below:

var result = $actions.GlobalClientAction();
var outValue = result.Out1;

Instead of typing "$actions.<client_action_name>()" in the code editor, you can drag-and-drop the client action either from the element tree below the code editor or from the "Logic" application layer tab to the code editor.

Hope this helps!

Regards,

Nordin

1. Make a client action (screen action) on your screen. In the case here it is "SampleClientAction".

2. Add a OnReady event to the screen.

3. Add a javascript the OnReady event. All you have to do is write this one line.

   setInterval(function(){$actions.SampleClientAction()}, 30000);

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