🚀 Welcome to MDriven Learn –  MDriven is now on Discord!  Don’t miss the latest Release Notes.
Remote Turnkey access
This page was created by Denis on 2018-05-23. Last edited by Wikiadmin on 2026-07-29.

You can connect one MDriven Turnkey application to another from an action, read or update remote ViewModel values, and use tab-separated grid data to synchronize changes between applications.

What remote Turnkey access does

Remote Turnkey access lets an MDriven-built application communicate with a separate MDriven Turnkey site. Your action opens a remote session, performs one or more reads or writes against a remote ViewModel, and closes the session.

Use it when two applications need to exchange data but do not share the same model. For example, a blue Turnkey site can fetch three values from a red Turnkey site and place them in fields in its own ViewModel. For larger updates, an application can transfer tab-separated grid data and import it into a target grid.

Remote access is implemented with OCL operators in actions. The two sites can have different models; the remote operation addresses the remote ViewModel through its ViewModel class ID and column names.

Before you start

Make sure that you have:

  • A source Turnkey site and a target Turnkey site that the calling site can reach by URL.
  • A ViewModel on the remote site that exposes the values you intend to read or change.
  • The remote ViewModel class ID and the exact name of each remote column you will address.
  • A user and password that can be looked up in the remote site's SysUser collection when authentication is required.
  • An action in the calling application's ViewModel where you will place the OCL logic.

Do not assume that the ViewModel class ID is the same value or format that you see in the browser URL. In the walkthrough, a read initially failed because the identifier copied from the URL was formatted differently from the ViewModel class ID required by the operator. Use the ViewModel class ID used by the remote Turnkey UI/data instead.

Build a remote read action

Create an action on the calling site's ViewModel to fetch values from a remote site.

  1. In MDriven Designer, open the ViewModel that will display or receive the imported values.
  2. Add an action, for example Fetch values from remote site. You can expose the action as a button using your normal ViewModel UI strategy.
  3. Declare a string variable to hold the remote session key. For example, name it vSession.
  4. Set vSession by calling RemoteTurnkeyConnectGetSessionKey. Supply the remote Turnkey root URL, user, and password.
  5. For each value to retrieve, use the remote string-value read operator with vSession, the remote ViewModel class ID, and the remote column name. Assign the returned value to the appropriate local ViewModel attribute.
  6. Close the remote session after the final operation.
  7. Upload or deploy the model, open the calling site, and run the action.

For example, an action on the blue site can connect to the red site, read remote columns Attribute1, Attribute2, and Attribute3, assign their values to corresponding local attributes, and then close the session. The important detail is that every remote read in this action uses the same session key returned by the connection operator.

Step Input or result
Connect Remote Turnkey root URL, user, and password; returns a session key.
Read Session key, remote ViewModel class ID, and remote column name; returns the remote string value.
Assign Store the returned value in a local ViewModel attribute.
Close End the remote session after the reads and writes are complete.

Keep related remote calls together in one action: connect once, perform the required operations with that session, then close it.

Write values to a remote ViewModel

To update a remote string value, first establish a session with RemoteTurnkeyConnectGetSessionKey, then use RemoteTurnkeySetStringValue.

RemoteTurnkeySetStringValue requires these parameters:

  • The session key returned by the connection operator.
  • The remote ViewModel class ID.
  • The remote column name.
  • The string value to set.

For example, after a user edits a local status field, an action can connect to the partner site and set the remote Status column to the local field's value. Close the session when the update is done.

The set-value operator can also send a complete tab-separated data block, not only a single field value. See the synchronization pattern below.

Synchronize grid data with tab-separated data

Turnkey provides grid export and import functions for transferring a collection of rows as tab-separated data. This is useful when the two applications need to merge changes rather than copy individual fields.

Export from the sending application

Use GetGridAsTabSepData with a ViewModel column to obtain the grid's data as a tab-separated string. The resulting string can be passed to a remote application through RemoteTurnkeySetStringValue.

For example, the sending site can export a grid of products and write the resulting text into a remote ViewModel column that receives import data.

Import on the receiving application

Implement an import action on the receiving site using ImportTabSepData. The first column is the key used to find the existing object represented by each imported row.

  • If the import finds a known key, it updates the matching object with the incoming values.
  • If the import encounters a key that it does not recognize, it can create a new object by calling the configured Create new action.

For example, a user can export rows from one site, change values in the tab-separated data, and run the import on the other site. Rows with existing keys are updated; a row with a new key can be created through the receiving grid's create-new logic.

Design the receiving ViewModel and its import action before sending data. The remote write only delivers the tab-separated string; the receiving application's import logic determines how keys are matched, which values are applied, and how new objects are created.

Test and troubleshoot

Test remote access with a small, visible read before transferring a full grid.

  1. Add one remote read to an action and assign its result to a local field that you can inspect in the UI.
  2. Verify the remote Turnkey URL, remote ViewModel class ID, and remote column name.
  3. Run the action from the calling site.
  4. If the value is not returned, inspect the Turnkey debug data and logs.
  5. After the single-value read works, add additional reads, remote writes, or the tab-separated synchronization flow.

When troubleshooting a ViewModel identifier, opening the Turnkey site with /debug after the form URL can show JSON data for the active UI. Compare that data with the identifier used in your action; do not rely only on the identifier's appearance in the normal URL.

Use Turnkey and MDrivenServer logs to investigate connection failures and server-side errors. The log documentation includes browser URLs for the Turnkey error and debug logs, plus the ShowDebugInfoPassword setting used when debug access is protected.

Security and operational considerations

  • Treat the remote Turnkey URL, user, and password as connection credentials. Configure access deliberately on the remote site.
  • Keep the session key in a local action variable and use it only for the operations in that action.
  • Close the session after completing remote reads and writes.
  • Test with a dedicated remote ViewModel and a small data set before enabling a synchronization action for production data.
  • When local development is sufficient, Local TurnkeyPrototyper can provide a quick feedback loop. It can run locally over HTTP; this does not remove the need to plan authentication and secure connectivity for deployed sites.

Walkthrough

The Remote Turnkey Access walkthrough demonstrates connecting a blue Turnkey site to a red site, storing the session in a string variable, reading remote ViewModel columns, diagnosing an incorrect ViewModel class ID through debug data, and using tab-separated grid export/import for synchronization.

See also