2638
Views
8
Comments
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:) 


2023-09-26 10-34-09
Cristiana Umbelino

Does this post from another Community Member help you?

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

2021-01-08 06-17-21
Pushpendra Singh

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

2021-01-08 06-17-21
Pushpendra Singh

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.

2021-08-12 11-00-27
Nordin Ahdi
 
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

2022-04-08 00-37-21
daichi ishikawa

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);

2025-10-16 10-02-51
Sohel Khan

Can you please help me with code of the java script how can we destroy this client action in on destroy event.

2023-04-14 11-47-10
Samuel Frade

When used function "setInterval()" you should also destroy it.

Error in Service Center: "Consider removing this call by using the 'On Destroy' event of the screen/block or moving your logic to a global client action. "

How to solve this: 
we can use "clearInterval()" whenever you don't need the setInterval() result or, as more common solution OnDestroy OS event. However you can try to clear existing interval instance first before creating new (OnReady p.e.)

More:
In case used in OnReady OS page event, everytime you open any page a new instance of setinterval is created. 

TIP:
To execute the function only once, use the setTimeout() method instead. 

UserImage.jpg
Hamilkar Barkas

Guys, i have similar problem to author of question - but have i can call client action with ... parameters?
i want

$actions.OdpowiedzOnClick(odp=4)
but calling action don't see this parameter - how you any idea?

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