Skip to main content

Notifications

Small and medium business | Business Central, N...
Suggested answer

Global Variable

Posted on by 10

How can i define a global variable and can use it another page

can anyone please help me out in this??

  • Suggested answer
    Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Global Variable

    You cannot access any variable defined in a single object to others except using them as the parameter to your function and still, they are available internally to that object. You can write a Return function and use a global variable for values but Navision does not allow multiple return functions

  • RockwithNav Profile Picture
    RockwithNav 6,562 on at
    RE: Global Variable

    And what is your core requirement?

    Can you please explain us a bit?

  • Suggested answer
    Nitin Verma Profile Picture
    Nitin Verma 21,091 Super User 2024 Season 1 on at
    RE: Global Variable

    Use SingleInstance propery set to Yet on Codeunit Object

    On Page1:

    Codeunit1.SetNumber(100);

    On Page2:

    Number := Codeunit1.GetNumber();

    MESSAGE(Format(Number));

    The SingleInstance property in Codeunit1 is set to Yes. Page1 calls a function on Codeunit1 and sets the parameter to 100. Codeunit1 saves this parameter in a local variable. Page2 is now able to get the parameter value (=100) from Codeunit1. A message is displayed.

  • Faaiz Ahmed Profile Picture
    Faaiz Ahmed 10 on at
    RE: Global Variable

    I want to access test variable in another page

    procedure combine(name1: Text)

       begin

           test := name1;

       end;

    // i wouldn't be able to access it  just access that method only. i want to access its member also

  • Faaiz Ahmed Profile Picture
    Faaiz Ahmed 10 on at
    RE: Global Variable

    Do you have any code example of it

  • Suggested answer
    Nitin Verma Profile Picture
    Nitin Verma 21,091 Super User 2024 Season 1 on at
    RE: Global Variable

    You can use global variables by creating a Codeunit and defining your customized procedures with some custom global variables into that and use that procedure with any of the objects.

    Cheers!

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

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Community AMA December 12th

Join us as we continue to demystify the Dynamics 365 Contact Center

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,240 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,149 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans