🚀 Welcome to MDriven Learn –  MDriven is now on Discord!  Don’t miss the latest Release Notes.
SysSingleton GetSystemUrl
This page was created by Hans.karlsen on 2018-08-06. Last edited by Wikiadmin on 2026-07-29.

You can expose the URL of the currently running SysSingleton Turnkey application to OCL and Action Language by modeling GetSystemUrl() as an ExternalLateBound operation.

What GetSystemUrl returns

SysSingleton.GetSystemUrl():String returns the URL address of the running Turnkey system. The returned value always ends with /.

For example, if the running system URL is https://example/, you can append a relative application path without adding another slash:

SysSingleton.oclSingleton.GetSystemUrl() + 'SiteAssets/ProjectReportTemplate.odt'

This produces a fully qualified URL to SiteAssets/ProjectReportTemplate.odt.

Add the operation to SysSingleton

In MDriven Designer, add the operation to your SysSingleton class, then configure it as an externally supplied operation.

  1. Select SysSingleton in the model.
  2. Add an operation named GetSystemUrl with return type String and no parameters.
  3. Set the operation tagged value Eco.ExternalLateBound to anyvalue.
  4. Mark the operation as IsQuery when you need to call it from OCL.

Eco.ExternalLateBound tells Turnkey that the operation is implemented by the running environment rather than by model code. Marking it as IsQuery makes it available in OCL; without that setting, you can use it from Action Language but not from OCL expressions.

Use the operation in OCL

Use the oclSingleton operator to access the single SysSingleton object.

SysSingleton.oclSingleton.GetSystemUrl()

The following example creates a URL to a report template stored under SiteAssets:

SysSingleton.oclSingleton.GetSystemUrl() +
'SiteAssets/ProjectReportTemplate.odt'

The trailing slash returned by GetSystemUrl() is significant. Append paths such as SiteAssets/..., not /SiteAssets/..., to avoid a double slash.

Example: URL in a QR image

You can use the full system URL when a QR code must lead the user back to an object in the application:

ZXing.QRImage(300,300,
  SysSingleton.oclSingleton.GetSystemUrl() +
  'Turnkey/AngularApp#/ToolInfo/' + self.Guid.asstring)

In this example, the QR image encodes a URL to the ToolInfo route for the current object's GUID.

Runtime scope and background work

GetSystemUrl() returns the URL of the Turnkey server. It is available only at the Turnkey level; it is not available at the MDrivenServer level.

A Turnkey-originated action must run before the system URL is available. This matters when later work runs outside the original web request, such as a server-side job or a SysAsync ticket on MDrivenServer. If that later work needs the URL, capture it during the Turnkey action and persist the value in an appropriate modeled location for the later job to use.

For example, an action initiated from Turnkey can read GetSystemUrl(), store the resulting URL with the work to be performed, and allow the background process to use that stored value instead of trying to resolve the current request URL.

Name

The operation name is GetSystemUrl, not GetServerUrl.

Related SysSingleton operations

Turnkey also exposes selected common operations on SysSingleton through Eco.ExternalLateBound. For hash and byte-string operations, see Documentation:SHA512ComputeHash, SHA256ComputeHash and BitConverterToString. For a Turnkey setting lookup, see Documentation:SysSingleton.MiscSetting.

See also