Options

can you access another codeunits variables during runtime via a get-Function?

kenyokenyo Member Posts: 40
Hi, so i wonder how long (global ) variable values are stored during runtime. Lets say i want to pass an error message (from CodeUnit A ) to another code unit ( CU B ) . could i for example store it in a global variable in CU A , call another CU B and then pull the global variable from CU A through a get-function? Or is there an even easier way ?
Cheers

Answers

  • Options
    TallyHoTallyHo Member Posts: 383
    edited 2019-04-05
    Yes, what you describe is possible. Global variables will keep their value during runtime.
    A self-written get-function is the proper way to do it.
    It can even be stored longer than runtime, using the single instance property of the Codeunit.

    But the normal way of doing things is passing variable from CU A to CU B when calling CU B.
  • Options
    Miklos_HollenderMiklos_Hollender Member Posts: 1,598
    Yes, but error messages have easier ways https://docs.microsoft.com/en-us/dynamics-nav/error-handling
Sign In or Register to comment.