🚀 Welcome to MDriven Learn –  MDriven is now on Discord!  Don’t miss the latest Release Notes.
Getting taggedvalues in runtime without code
This page was created by Alexandra on 2018-10-21. Last edited by Wikiadmin on 2026-07-29.

You can read tagged values from your model at runtime in an OCL expression, so a model-driven application can use model metadata without writing code.

A tagged value is metadata stored on a model element. In a runtime expression, the taggedValue and taggedValueOnFeature OCL operators return the tagged-value value as a string.

Read a tagged value from a class

Use oclType to get the runtime object's class, then call taggedValue with the tagged-value name.

G.allinstances->first.oclType.taggedValue('Eco.PresentationUnit')

In this example:

  • G.allinstances->first selects one runtime instance of G.
  • oclType gets that instance's model class.
  • taggedValue('Eco.PresentationUnit') reads the Eco.PresentationUnit tagged value defined on the class.

Use this pattern when the tagged value is set on the class itself. For the operator definition and a shorter example, see Documentation:OCLOperators taggedValue.

Read a tagged value from an attribute or association end

A class-level lookup does not read tagged values set on a feature. A feature is an attribute or an association end on a class. To read metadata from a feature, call taggedValueOnFeature on the class type.

G.allinstances->first.oclType.taggedValueOnFeature('SomeAttribute', 'Eco.PresentationUnit')

The arguments are:

Position Value Example
First The feature name: an attribute or association end on the class. 'SomeAttribute'
Second The tagged-value name to read from that feature. 'Eco.PresentationUnit'

For example, if the SomeAttribute attribute of G has a tagged value named Eco.PresentationUnit, the expression returns that value as a string.

See Documentation:OCLOperators taggedValueOnFeature for the operator reference.

Use the expressions in your model

  1. In MDriven Designer, select the expression field where you need the metadata value, such as an expression used by your ViewModel or rule.
  2. Identify where the tagged value is defined: on the class, or on a named attribute or association end.
  3. Use oclType.taggedValue('TagName') for a class-level tagged value.
  4. Use oclType.taggedValueOnFeature('FeatureName', 'TagName') for a feature-level tagged value.
  5. Replace the example names with the exact tagged-value and feature names from your model.

Keep the tagged value on the model element that owns the information. For example, a presentation-unit setting for a specific attribute belongs on that attribute and is read with taggedValueOnFeature, while metadata that applies to every instance of a class belongs on the class and is read with taggedValue.

Manage tagged values in MDriven Designer

You can add and inspect tagged values in the tagged-value editor in MDriven Designer. The editor is available where tagged values are accessed. Select Refresh From Wiki to update the available help and type-sensitive tagged-value information. See Documentation:Tagged values in the Designer.

For tagged values that affect client rendering, consult Documentation:Important TaggedValues for MDriven Turnkey Web-UI is found Here or Documentation:Important TaggedValues for MDriven WPF Fat client rather than duplicating those settings in expressions.

See also