web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

Session Id :
Small and medium business | Business Central, N...
Answered

Referencing Variable Names

(0) ShareShare
ReportReport
Posted on by 237

Hello,

Is it possible to reference different variables with one AL statement?

For example, Label variables are defined like

Label01: Label 'aaaaa';

Label02: Label 'bbbbb';

Label03: Label 'ccccc';

And instead of referencing each variable with 3 AL lines, referencing like

Value := Labelnn;

(where nn is 01, 02, 03)

I have a feeling that this is not possible, but if anyone knows the solution to this, please advise.

Thank you!

I have the same question (0)
  • Verified answer
    Teddy Herryanto (That NAV Guy) Profile Picture
    14,306 Super User 2026 Season 1 on at

    Don't really know why you want to do that.

    Answer is no.

  • Suggested answer
    YUN ZHU Profile Picture
    99,978 Super User 2026 Season 1 on at

    Hi, I think you can try the array.

    A very simple example:

    pastedimage1634514851724v1.png

    Hope this will help.

    Thanks.

  • adams1124 Profile Picture
    237 on at

    Thank you, Teddy.

  • adams1124 Profile Picture
    237 on at

    Thank you, Zhu. I should have been more specific.

    What I wondered if I could do is to reference the label variables in one statement.

    ...

    Label1: Label 'aaaaa';

    Label2: Label 'bbbbb';

    Label3: Label 'ccccc';

    Name: Text;

    n: integer;

    ...

           for n := 1 to 3 do begin

               Name := Labeln;

              (do something using Name)

           end;

    ...

    So the name of the variable needs to be referenced "as variable", like "Labeln".

    I guess it is not possible with AL and in the case above, I need to write the process for each Label variable (Label1, Label2, Label3).

  • Verified answer
    YUN ZHU Profile Picture
    99,978 Super User 2026 Season 1 on at

    Hi, yes, as Teddy said, it is not possible.

    But if you want to reduce the number of variables, I think arrays are also a good choice.

    For example.

    pastedimage1634522033682v1.png

    Hope this will help.

    Thanks.

    ZHU

  • adams1124 Profile Picture
    237 on at

    Thank you, Zhu.

    I will try as you advised.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Stars!

Meet the Microsoft Dynamics 365 Contact Center Champions

We are thrilled to have these Champions in our Community!

Congratulations to the March Top 10 Community Leaders

These are the community rock stars!

Leaderboard > Small and medium business | Business Central, NAV, RMS

#1
OussamaSabbouh Profile Picture

OussamaSabbouh 1,796 Super User 2026 Season 1

#2
YUN ZHU Profile Picture

YUN ZHU 965 Super User 2026 Season 1

#3
Teagen Boll Profile Picture

Teagen Boll 664 Super User 2026 Season 1

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans