Skip to main content

Developing an Application



Encapsulate Logic and Reuse It

In OutSystems, to promote reusability and abstraction you can create actions and later invoke them in other action flows. This allows you to centralize the logic and makes it easier to maintain. For example, you change it in only one place and everyone using it will benefit.

To encapsulate logic in an action:

  1. In the Logic tab, create a Client or Server action, depending on if you want to execute this logic in the device or in the server.
  2. Implement the logic in the action flow.

To use the encapsulated logic in another action:

  1. Open that action’s flow.
  2. Drag the action with the encapsulated logic from the Logic tab and drop it in the flow.
  3. Set the values of the input and output parameters, if any.


In GoOutWeb, an application for finding and reviewing places, we can create or update a Place by using the CreateOrUpdatePlace entity action. However, we want to be sure a place is valid before creating or updating it in the database. In that way, we want to create an action that validates a Place before and, if valid, stores it in the database. This action will be used in all situations where we want to create or update a Place.

To create the action:

  1. Go to the Logic tab , right-click on the Server Actions folder, and add the new server action. Name it Place_CreateOrUpdate.

  2. Add the following input parameter:

    • Place of type Place.
  3. Add the following output parameters:

    • PlaceId of type Place Identifier.
    • ErrorMessage of type Text.
    • Success of type Boolean (set the default to True).
  4. Implement the logic:

    1. Validate that the Name and Address attributes are not empty.
    2. Execute CreateOrUpdatePlace and assign the Id to the output parameter PlaceId.

To use this action in the creation or update of places in the GoOutWeb application:

  1. In the Interface tab, find the PlaceEdit screen, and open the Save screen action.
  2. Drag the Place_CreateOrUpdate action from the logic tab to the action flow.
  3. Pass the place data to the action: PlaceForm.Record.Place.
  4. Use the returned values (PlaceId, Success, and ErrorMessage) to give feedback to the end-user.
  5. Publish and test.

One other situation for using this action is in the GoOut application, the mobile version of the GoOutWeb application. It happens when an end-user wants to write a review for a place that is not on the list. The place has to be created along with the review.

To implement this case learn also how to Expose and Reuse Code between Modules.