🚀 Welcome to MDriven Learn –  MDriven is now on Discord!  Don’t miss the latest Release Notes.
FollowEnable
This page was created by Hans.karlsen on 2024-01-10. Last edited by Wikiadmin on 2026-07-29.

You can use FollowEnable on a ViewModel column in MDriven Designer to keep its visibility synchronized with the inverse of its ReadOnlyExpression, without maintaining two expressions.

What FollowEnable does

A ReadOnlyExpression determines when a ViewModel column is read-only. A VisibleExpression determines when the column is shown.

Enable FollowEnable for the VisibleExpression when the column should be visible exactly when it is not read-only. MDriven then uses the negated ReadOnlyExpression as the VisibleExpression.

You define FollowEnable result
self.ThisShouldBeReadOnlyAndInvisible as the ReadOnlyExpression The effective visibility is not self.ThisShouldBeReadOnlyAndInvisible

This avoids duplicating the condition in two places. If you later change the ReadOnlyExpression, the derived visibility remains aligned with it.

Configure FollowEnable

  1. In the ViewModelEditor, select the ViewModel column you want to configure.
  2. Enter the condition in the column's ReadOnlyExpression.
  3. Locate VisibleExpression.
  4. Select the FollowEnable checkbox next to VisibleExpression. A checkmark indicates that FollowEnable is active.
  5. Save the model and run the application.
  6. Test both outcomes of the ReadOnlyExpression. Confirm that the column is shown when it is editable and hidden when it is read-only.

Example: show an administrator-only field

In Training:Bootcamp:Chapter 12, the BrandOfCarForAdmin column is intended to be editable only by an administrator. Its ReadOnlyExpression is:

not SysSingleton.oclSingleton.CurrentUser.IsAdmin

The expression is true for a user who is not an administrator, so the column is read-only for that user. With FollowEnable selected for VisibleExpression, the effective visibility is:

not (not SysSingleton.oclSingleton.CurrentUser.IsAdmin)

The column is therefore visible to an administrator and invisible to a non-administrator. Test with both an administrator account and a non-administrator account.

Example: show Save only when it is enabled

Training:Bootcamp:Chapter 8 uses the same maintenance pattern for a Save column. The Save action has a DisableExpression that disables it when there are no changes:

selfVM.Dirtylist->isempty

When its visibility is made to follow the inverse enable state, the Save action is shown only when the dirty list is not empty. This prevents users from seeing a Save action when there is nothing to save.

When to use it

Use FollowEnable when both statements are true:

  • The same condition that makes the column read-only should also hide it.
  • The visibility rule is the exact negation of the read-only rule.

Do not use FollowEnable when visibility has a different business rule. In that case, write and maintain a separate VisibleExpression.

Maintenance note

FollowEnable derives visibility from the ReadOnlyExpression. If you move or remove the ReadOnlyExpression, review the FollowEnable checkmark as part of the change. For example, the Chapter 12 exercise removes the checkmark before moving the read-only condition from a column to the containing ViewModel.

See also