How is your experience with the OutSystems Community?
36
Views
7
Comments
Calling server actions dynamically between application
Question

Hi everyone, 

I have a scenario involving two applications: 

APP1: This application has a set of server actions. 

APP2: In this application, I’ve created an entity to store server action names and other set of data. 

Requirement 

In APP2, I have a detail screen for a specific record with a button. On clicking this button, I want to call the specific server action. The button action should be same, but based on the name in record the specific server action should be invoked.

Question 

Is it possible to dynamically call a server action based on name stored in an entity in APP2? 

If yes, could you guide me how to implement it

If no, then is there any other possible way or solution to my requirement?

Thanks in advance for your help!

2026-01-28 16-57-48
Mihai Melencu
Champion

Hi @Gowtham ,

Out-of-the-box, you cannot dynamically call a Server Action in OutSystems based only on its name stored in an entity. APP2 still needs to reference the actions from APP1, and the calls need to be explicitly defined in the logic.

A possible approach would be to create an orchestration/dispatcher action that receives the action name as input. Inside that action, you can use a Switch to decide which referenced Server Action should be called.

There is an old article about this here: How to dynamically call an action in Outsystems, based on the eSpace name and Action name. – Knowledgebase  .

And a forge component based on it: Action Reflection - Overview (O11) | OutSystems .

You could take a look at them and see how the logic is implemented and see if you can replicate it in ODC.

2023-10-30 06-03-17
Gowtham

Thanks @Mihai Melencu for your answer. Is this approach possible through API's. Exposing actions as API in one application. Storing the API URL in an entity in another application. Based on record specific API endpoint dynamically call the API. APP1 may be exposing multiple API/methods but in APP2 in need to consume only one API, and that API should dynamically change URL and call the specific API. Is this possible? If so how can I implement it.

2024-01-31 05-29-41
Akshay Deshpande

Hello @Gowtham


Yes, this is possible, but not by dynamically invoking OutSystems Server Actions by name. For external APIs, the recommended approach is: 

Store API Base URL and configuration in Entity/Site Properties.

Use REST APIs with dynamic Base URL (OnBeforeRequest or Extension logic). 
Keep one wrapper action in APP2 to decide which API endpoint to call. 

Important:
OutSystems Server Actions are compile-time references, so they cannot be executed dynamically from a string value. 
External REST endpoints can be dynamic because the URL is resolved at runtime.

 Best practice:
Use a Strategy/Dispatcher pattern instead of trying to execute actions by name dynamically.

This adds the architectural distinction clearly:

  • Server Actions → static
  • External APIs → dynamic


Thanks and Regards,
Akshay Deshpande

2023-10-30 06-03-17
Gowtham

Thanks @Akshay Deshpande for you reply.

I have created attributes in the entity to store the base url and endpoint. Can you guide me on how to change the URL dynamically in on_before_request. An OML with sample would be helpful.


Thanks,

Gowtham

2024-01-31 05-29-41
Akshay Deshpande

You can dynamically change the API Base URL at runtime based on DB values.

Example approach:

  1. Store in Entity:
  • BaseURL
  • APIName
  • Endpoint
  • ActiveFlag
  1. In APP2, fetch the config record based on your screen/action logic.
  2. In the consumed REST API → use OnBeforeRequest:

Request.BaseURL = APIConfig.BaseURL

or

Request.URL = APIConfig.BaseURL + "/customers/get"

depending on how your REST method is configured.

  1. Use one wrapper/dispatcher action:

Switch APINameCase "CustomerAPI":    CustomerAPI.GetCustomers()Case "OrderAPI":    OrderAPI.GetOrders()

Important distinction:

  • Dynamic REST endpoint URL → Supported
  • Dynamic execution of OutSystems Server Actions by string name → Not supported

Best practice: Keep all API routing logic centralized in one wrapper action for easier maintenance and governance.

I do not have a ready reusable OML currently, but the above pattern is the recommended in your case.


Thanks and regards,
Akshay Deshpande

2025-08-07 06-30-56
Amit J
Champion

No, OutSystems does not support invoking a Server Action dynamically by its name stored in a database or variable. Server Actions are statically bound at compile time, so you cannot execute an action simply by passing its name as a string.

A few alternative approaches you could consider:

  1. Dispatcher/Router Pattern (Recommended)

    • Create a single Server Action in APP1 (e.g., ExecuteAction).
    • Pass the action name as an input parameter.
    • Use a Switch/If statement to route the execution to the appropriate Server Action.
    • Example:

    Switch ActionName

    - "ActionA" -> Call ActionA
    - "ActionB" -> Call ActionB- "ActionC" -> Call ActionC

  2. Expose REST APIs
    • If the actions are independent business operations, expose them as REST APIs in APP1.
    • Store the API endpoint or operation identifier in APP2.
    • Invoke the appropriate API based on the stored configuration.

In most cases, the Dispatcher/Router Pattern is the simplest and most maintainable solution. It keeps all execution logic centralized while allowing APP2 to remain configuration-driven.

2023-10-30 06-03-17
Gowtham

Thanks everyone for you replies and spending your time for my question. I have found a solution for my usecase in the following post - https://www.outsystems.com/forums/discussion/106462/calling-apis-dynamically-between-two-applications/

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