{"id":32283,"date":"2026-07-28T13:51:49","date_gmt":"2026-07-28T13:51:49","guid":{"rendered":"https:\/\/www.greytrix.com\/blogs\/sagex3\/?p=32283"},"modified":"2026-07-28T13:51:49","modified_gmt":"2026-07-28T13:51:49","slug":"how-to-find-the-current-index-of-a-dimension-field-in-sage-x3-4gl","status":"publish","type":"post","link":"https:\/\/www.greytrix.com\/blogs\/sagex3\/2026\/07\/28\/how-to-find-the-current-index-of-a-dimension-field-in-sage-x3-4gl\/","title":{"rendered":"How to Find the Current Index of a Dimension Field in Sage X3 4GL"},"content":{"rendered":"\n<p>When working with <a href=\"https:\/\/www.greytrix.com\/sage-x3-erp\/development-services\/\" target=\"_blank\" data-type=\"link\" data-id=\"https:\/\/www.greytrix.com\/sage-x3-erp\/development-services\/\" rel=\"noreferrer noopener\">Sage X3<\/a> 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.<\/p>\n\n\n\n<p>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.<\/p>\n\n\n\n<p>In this article, you&#8217;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.<\/p>\n\n\n\n<p><strong>New Stuff: <\/strong><a href=\"https:\/\/www.greytrix.com\/blogs\/sagex3\/2026\/07\/23\/auto-packaging-in-shipeazy-for-sage-x3-smarter-shipment-packing\/\" target=\"_blank\" data-type=\"link\" data-id=\"https:\/\/www.greytrix.com\/blogs\/sagex3\/2026\/07\/23\/auto-packaging-in-shipeazy-for-sage-x3-smarter-shipment-packing\/\" rel=\"noreferrer noopener\">Auto Packaging in ShipEazy for Sage X3 | Smarter Shipment Packing<\/a><\/p>\n\n\n\n<p><strong>Understanding Dimension Fields in Sage X3<\/strong><\/p>\n\n\n\n<p>A dimension field (also called an array field) contains multiple indexed values under a single field definition.<\/p>\n\n\n\n<p>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.<\/p>\n\n\n\n<p>When you attach a field action (such as After Change) to a dimension field, the action is executed for every dimension.<\/p>\n\n\n\n<p>This behavior is standard in Sage X3, but it can become a problem if your business logic should only run for one specific dimension.<\/p>\n\n\n\n<p><strong>Why Do You Need the Current Dimension Index?<\/strong><\/p>\n\n\n\n<p>Consider the following scenario:<br>\u2022You have a field with 2 dimensions.<br>\u2022An After Change action is attached to that field.<br>\u2022Whenever the user changes either dimension, the action is triggered.<\/p>\n\n\n\n<p>Suppose your requirement is:<br>\u2022Execute custom logic only when the second dimension is modified.<br>\u2022Ignore changes made to the first dimension.<\/p>\n\n\n\n<p>Without knowing which dimension triggered the action, you cannot apply the correct condition.<\/p>\n\n\n\n<p>This is where the standard variable indice becomes useful.<\/p>\n\n\n\n<p><strong>The Solution: Using the indice Variable<\/strong><\/p>\n\n\n\n<p>Sage X3 provides a standard variable called indice.<\/p>\n\n\n\n<p>The indice variable returns the current index of the dimension field that triggered the action.<\/p>\n\n\n\n<p><strong>Syntax<\/strong><br>indice<\/p>\n\n\n\n<p>There is no special function or declaration required. Simply use the variable inside your 4GL action.<\/p>\n\n\n\n<p><strong>How indice Works<\/strong><\/p>\n\n\n\n<p>The indice variable returns an integer value representing the current dimension index.<\/p>\n\n\n\n<p>One important point to remember is:<br>                          <strong>Sage X3 4GL uses zero-based indexing.<\/strong><\/p>\n\n\n\n<p>This means:<\/p>\n\n\n\n<figure class=\"wp-block-table alignleft\"><table class=\"has-fixed-layout\"><tbody><tr><td><strong>Dimension on Screen<\/strong><\/td><td><strong>indice Value<\/strong><\/td><\/tr><tr><td>First Dimension <\/td><td>0<\/td><\/tr><tr><td>Second Dimension<\/td><td>1<\/td><\/tr><tr><td>Third Dimension<\/td><td>2<\/td><\/tr><tr><td>Fourth Dimension<\/td><td>3<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p><\/p>\n\n\n\n<p><\/p>\n\n\n\n<p><\/p>\n\n\n\n<p class=\"has-text-align-left\"><\/p>\n\n\n\n<p><\/p>\n\n\n\n<p><strong>Practical Example<\/strong><\/p>\n\n\n\n<p>Imagine you have a field with 2 dimensions and have attached an After Change action.<\/p>\n\n\n\n<p><strong>User Action<\/strong><\/p>\n\n\n\n<p>\u2022User edits the <strong>first dimension<\/strong><br>           indice = 0<br>\u2022User edits the <strong>second dimension<\/strong><br>           indice = 1<\/p>\n\n\n\n<p>You can then write conditional logic based on the returned value.<\/p>\n\n\n\n<p><strong>Example:<\/strong><br>If indice = 1<br># Execute logic only for the second dimension<br>Endif<\/p>\n\n\n\n<p>This ensures that your code runs only when the second dimension changes, while ignoring changes made to the first dimension.<\/p>\n\n\n\n<p><strong>Testing the indice Variable<\/strong><\/p>\n\n\n\n<p>A simple way to verify how indice works is to display its value whenever the field changes.<\/p>\n\n\n\n<p>For example, if you add a popup or message displaying the value of indice inside the After Change action:<br>\u2022Editing the first dimension displays 0<br>\u2022Editing the second dimension displays 1<br>\u2022Editing the third dimension displays 2, and so on<\/p>\n\n\n\n<p>This confirms which dimension triggered the action.<\/p>\n\n\n\n<p><strong>Key Points to Remember<\/strong><\/p>\n\n\n\n<p>\u2022indice is a standard Sage X3 variable.<br>\u2022It returns the current dimension index.<br>\u2022The index is zero-based.<br>\u2022It is especially useful in field actions such as:<br>\u2022After Change<br>\u2022Before Entry<br>\u2022After Entry<br>\u2022Other field-level actions involving dimension fields<br>\u2022Use indice to execute logic only for specific dimensions.<\/p>\n\n\n\n<p><strong>Conclusion<\/strong><\/p>\n\n\n\n<p>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.<\/p>\n\n\n\n<p>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.<\/p>\n\n\n\n<p>If you&#8217;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.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>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,\u2026 <span class=\"read-more\"><a href=\"https:\/\/www.greytrix.com\/blogs\/sagex3\/2026\/07\/28\/how-to-find-the-current-index-of-a-dimension-field-in-sage-x3-4gl\/\">Read More &raquo;<\/a><\/span><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[8,13],"tags":[20,493,592,1062,4580],"class_list":["post-32283","post","type-post","status-publish","format-standard","hentry","category-sage-erp-x3","category-integration","tag-4gl","tag-customization","tag-dimension","tag-index","tag-indice"],"_links":{"self":[{"href":"https:\/\/www.greytrix.com\/blogs\/sagex3\/wp-json\/wp\/v2\/posts\/32283","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.greytrix.com\/blogs\/sagex3\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.greytrix.com\/blogs\/sagex3\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.greytrix.com\/blogs\/sagex3\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.greytrix.com\/blogs\/sagex3\/wp-json\/wp\/v2\/comments?post=32283"}],"version-history":[{"count":3,"href":"https:\/\/www.greytrix.com\/blogs\/sagex3\/wp-json\/wp\/v2\/posts\/32283\/revisions"}],"predecessor-version":[{"id":32286,"href":"https:\/\/www.greytrix.com\/blogs\/sagex3\/wp-json\/wp\/v2\/posts\/32283\/revisions\/32286"}],"wp:attachment":[{"href":"https:\/\/www.greytrix.com\/blogs\/sagex3\/wp-json\/wp\/v2\/media?parent=32283"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.greytrix.com\/blogs\/sagex3\/wp-json\/wp\/v2\/categories?post=32283"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.greytrix.com\/blogs\/sagex3\/wp-json\/wp\/v2\/tags?post=32283"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}