Skip to main content

Developing an Application

 

OutSystems

Create and Use Variables to Configure Behaviors at Runtime

OutSystems allows creating variables that are stored and changed at the environment level. They are normally used to implement application behaviors that are configurable at runtime. And remove the need of redeploying the application. These variables are known as Site Properties.

When a Site Property is created, it is set by the developer with a default value. At runtime, someone with privileges can change its value through the environment management console.

To create and use a Site Property, do as follows:

  1. In the Data tab, right-click on the Site Properties folder, and add a site property;
  2. Define the name, data type, and its default value;
  3. Use in your code by referring to it as Site.<SitePropertyName>.

In a mobile application, a Site Property can only be used:

  • Go to the web application:
  1. Create an action that returns the site property value. Expose the action to reuse it in the mobile application.

  • Go to the mobile application:
  1. Add a dependency to the action created in the web application;

  2. Implement the logic that needs the value of the site property.

Example in a Web Application

The GoOutWeb is a web application for finding, reviewing, and rating places. It also allows reporting reviews as inappropriate. Now, we want to block the access to the application to end-users who exceed a number of reviews reported and confirmed as inappropriate.

At the start, the limit is three, but we want to be able to adjust it in time without having to redeploy the application.

We have to create a Site Property and use it to check the limit of confirmed reports per end-user:

  1. In the Data tab, right-click on the Site Properties folder to add the site property:
    1. Name it MaxReportedReviews;
    2. Set its data type to Integer;
    3. Set the default value to 3.
  2. Go to the ReportedReviews screen and open the Confirm screen action;
  3. After updating the review as inactive, add an Aggregate to count inactive reviews with reports per end-user;
  4. Iterate the aggregate results and:
    1. Check if the count exceeds Site.MaxReportedReviews;
    2. If True, put the end-user as inactive.
  5. Publish and test.

Example in a Mobile Application

The GoOutWeb web application has a configuration (in a Site Property) for minimum length a comment must have in reviews. We want to have this same behavior in reviews entered in the GoOut mobile application.

Go to the web application:

  1. Create an action called SiteProperty_MinimumCommentLength that returns the value of the Site.MinimumCommentLength site property;

  2. Expose the action and publish the application.

Go to the mobile application:

  1. Add a dependency to the SiteProperty_MinimumCommentLength action;

  2. Go to the WriteReview screen and, in the Save client action:

    1. Call the SiteProperty_MinimumCommentLength action to get the site property value;

    2. Implement the logic to validate the size of the comment.

  3. Publish and test.

  • Was this article helpful?