🚀 Welcome to MDriven Learn –  MDriven is now on Discord!  Don’t miss the latest Release Notes.
OCLOperators externalId
This page was created by Peter on 2019-11-18. Last edited by Wikiadmin on 2026-07-29.

You can use the externalId OCL operator when you need the MDriven external identity of an object for an integration, export, or object link.

Syntax

object.externalId

The operator returns the external identity for the object on the left side of the expression.

Returned value

An ExternalId commonly has the form classindex!objectid. For example, 9!10 identifies an object with primary key 10 in the class represented by class index 9.

The class part is required so that MDriven can determine the class in which the object resides. Class indexes can change when you update the model. If you expose identifiers outside the system, such as in saved links or integrations, review The ExternalId explained for class-name and Guid-property forms that are more resilient to model changes.

Examples

Get one object's ExternalId

Customer.allInstances->first.externalId

This expression returns the ExternalId of the first Customer object in the collection.

For example, if that customer has class index 9 and object ID 10, the result can be 9!10.

Collect ExternalIds from a set of objects

Customer.allInstances->collect(c | c.externalId)

This expression returns a collection containing one ExternalId for each Customer. Use this pattern when creating an export that must include both customer data and an identifier that can later be used to locate each customer.

Resolve an ExternalId back to an object

Use objectfromExternalId for the reverse operation: resolving an external identity to its object. That operator also supports specified alternative forms, including matching a property named Guid and class-name-based identity input.

Usage guidance

  • Use externalId when the receiving process needs an MDriven object identity.
  • Do not assume that a numeric class index remains unchanged after a model update.
  • For identifiers placed in externally saved URLs or other long-lived references, use the guidance in The ExternalId explained.
  • Do not confuse an ExternalId with a VMClassId, which also contains ViewModel context.

See also