You use objectfromExternalId in OCL to resolve an external identity to its corresponding object.
Resolve an object from an external identity
An external identity is the value produced by externalId for an object. Pass that identity to objectfromExternalId when you need to work with the object that the identity represents.
For example, one part of an expression can retain an object's external identity, while a later expression resolves that value back to the object with objectfromExternalId.
Resolution alternatives
In addition to resolving the supplied external identity, objectfromExternalId tries the alternatives below.
| Supplied value or model condition | Resolution behavior | Example |
|---|---|---|
An external identity produced by externalId
|
Resolves the identity to its object. | Resolve the external identity previously obtained for an object. |
The class has a property named Guid, typed as Guid or string, and its value matches the supplied value
|
Resolves the object whose Guid property matches the value.
|
If an object's Guid property contains a matching GUID value, that object is resolved.
|
A value in the form TheClassName;number
|
Uses the class name to obtain the internal class ID, then attempts to resolve the resulting value as an external identity. | Customer;42 follows this class-name-and-number form when Customer is the class name and 42 is the number.
|
Use the expected identifier format
- Use the value from
externalIdwhen you already have an external identity. This is the normal round-trip scenario. - Use a matching
Guidvalue only when the target class defines a property named exactlyGuidand that property is typed asGuidorstring. - Use the
TheClassName;numberform only when the value is available in that format. The class-name portion must identify the class from which the internal class ID is obtained.
Do not treat an external identity as a display value. Store and pass the identity unchanged when you intend to resolve the same object later.
Related concepts
objectfromExternalId performs the reverse operation of externalId: externalId obtains an object's external identity, and objectfromExternalId resolves that identity back to an object. For the broader identifier model, see The ExternalId explained.
