How to Find the Current Index of a Dimension Field in Sage X3 4GL

By | July 28, 2026

When working with Sage X3 4GL, developers often customize screens by adding actions such as After Change, Before Entry, or After Entry to fields. However, things become a little more complex when the field is a dimension (array) field.

A common challenge is that a field action is triggered for every dimension of the field, even when your customization should only apply to a specific one. In such cases, knowing the current dimension index becomes essential.

In this article, you’ll learn how to identify the current index of a dimension field in Sage X3 4GL using the standard indice variable and how to use it effectively in your customizations.

New Stuff: Auto Packaging in ShipEazy for Sage X3 | Smarter Shipment Packing

Understanding Dimension Fields in Sage X3

A dimension field (also called an array field) contains multiple indexed values under a single field definition.

For example, a field with 2 dimensions appears as two separate input fields on the screen. Although they look like individual fields, they are actually different indexes of the same field.

When you attach a field action (such as After Change) to a dimension field, the action is executed for every dimension.

This behavior is standard in Sage X3, but it can become a problem if your business logic should only run for one specific dimension.

Why Do You Need the Current Dimension Index?

Consider the following scenario:
•You have a field with 2 dimensions.
•An After Change action is attached to that field.
•Whenever the user changes either dimension, the action is triggered.

Suppose your requirement is:
•Execute custom logic only when the second dimension is modified.
•Ignore changes made to the first dimension.

Without knowing which dimension triggered the action, you cannot apply the correct condition.

This is where the standard variable indice becomes useful.

The Solution: Using the indice Variable

Sage X3 provides a standard variable called indice.

The indice variable returns the current index of the dimension field that triggered the action.

Syntax
indice

There is no special function or declaration required. Simply use the variable inside your 4GL action.

How indice Works

The indice variable returns an integer value representing the current dimension index.

One important point to remember is:
Sage X3 4GL uses zero-based indexing.

This means:

Dimension on Screenindice Value
First Dimension 0
Second Dimension1
Third Dimension2
Fourth Dimension3

Practical Example

Imagine you have a field with 2 dimensions and have attached an After Change action.

User Action

•User edits the first dimension
indice = 0
•User edits the second dimension
indice = 1

You can then write conditional logic based on the returned value.

Example:
If indice = 1
# Execute logic only for the second dimension
Endif

This ensures that your code runs only when the second dimension changes, while ignoring changes made to the first dimension.

Testing the indice Variable

A simple way to verify how indice works is to display its value whenever the field changes.

For example, if you add a popup or message displaying the value of indice inside the After Change action:
•Editing the first dimension displays 0
•Editing the second dimension displays 1
•Editing the third dimension displays 2, and so on

This confirms which dimension triggered the action.

Key Points to Remember

•indice is a standard Sage X3 variable.
•It returns the current dimension index.
•The index is zero-based.
•It is especially useful in field actions such as:
•After Change
•Before Entry
•After Entry
•Other field-level actions involving dimension fields
•Use indice to execute logic only for specific dimensions.

Conclusion

When working with dimension fields in Sage X3 4GL, field actions are executed for every dimension by default. If your customization should apply only to a specific dimension, the standard indice variable provides a simple and reliable solution.

Since indice returns the current dimension index using zero-based numbering, you can easily identify which dimension triggered the action and write targeted conditional logic. This approach keeps your code cleaner, avoids unnecessary processing, and makes your Sage X3 customizations more precise and maintainable.

If you’re developing custom screens or field validations in Sage X3, understanding and using the indice variable is a small but valuable technique that can save time and simplify your development.