Runtime external object

Official Content
This documentation is valid for:

The Runtime external object allows the developer to differentiate, at runtime, when the application executes some action on the client-side or on the server-side.  Its purpose is to allow the developer to make decisions programmatically to be consistent with the business logic of the system (e.g. determine the insert timestamp of a new record, which can differ between the client or the server during the synchronization). 

Runtimeexternalobject-Location_png image_201861211374_1_png

Properties

Environment property

It is based on the RuntimeEnvironment domain (described below) that provides the environment information in which the called action was executed.

  SD Online SD Offline Web
Start event Server Device Server
Refresh event Server Device Server
Load event Server Device Server
Procedure object Server Device Server
Business Component rules Server Device Server
ClientStart event & Navigation Start events Device Device N/A
User defined event Device Device Browser

Methods

It does not have any.

Events

It does not have any.

Domains

RuntimeEnvironment domain

Enumerated domain describing the possible runtime environments.

Server Server-side
Device Client-side on the Smart Device environment
Browser  Client-side on Web environment.

Examples

This section provides some simple use cases where the Runtime external object might be useful.

  1. Gap during synchronization
    In an offline smart device application, when a new record is inserted in the database, this record will adopt the device timestamp (the real one), but after the synchronization, the server will persist another. This problem can be avoided if the developer takes control when the record is physically inserted.

    Suppose you have the following transaction:
    Task
    {
       TaskId*      : Numeric(4.0)
       TaskAbstract : Character(200) 
       TaskCreated  : DateTime
    }
    Rules
       noaccept(TaskCreated);
       TaskCreated = now() if insert;
    
    If the application is offline, which will be the TaskCreated timestamp value? The moment when the record is inserted on the offline database or when is inserted in the server database? For avoiding this problem, you can include TaskSynced attribute (DateTime base too), and differentiate both cases as follows:
    Task
    {
       TaskId*      : Numeric(4.0)
       TaskAbstract : Character(200) 
       TaskCreated  : DateTime
       TaskSynced   : DateTime
    }
    Rules
       noaccept(TaskCreated);
       noaccept(TaskSynced);
       TaskCreated = now() if insert and Runtime.Environment = RuntimeEnvironment.Device;
       TaskSynced  = now() if insert and Runtime.Environment <> RuntimeEnvironment.Device;
    
     
  2. Offline notifications
    When a smart device application works in an offline architecture, the process for sending notifications must be controlled in order to be sent by the server (not the device). This problem can be avoided analogously to the use-case (1) by restricting the execution to only when it's from the server (RuntimeEnvironment.Server).

Scope

Platforms  SmartDevices(Android, iOS)

Availability

This external object is available as from GeneXus 15.



Was this page helpful?
What Is This?
Your feedback about this content is important. Let us know what you think.