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

Notifications

Announcements

No record found.

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,284 Super User 2025 Season 2 on at

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

    Answer is no.

  • Suggested answer
    YUN ZHU Profile Picture
    95,597 Super User 2025 Season 2 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
    95,597 Super User 2025 Season 2 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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

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

#1
OussamaSabbouh Profile Picture

OussamaSabbouh 2,785

#2
Jainam M. Kothari Profile Picture

Jainam M. Kothari 1,007 Super User 2025 Season 2

#3
YUN ZHU Profile Picture

YUN ZHU 948 Super User 2025 Season 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans