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 :
Business Central forum

Events in Business Central

(0) ShareShare
ReportReport
Posted on by 245


I am writing code in event like " i:=i+1 " , I want increment i ( i is global variable in my custom Code unit) value when event triggered(the event is exist in "Repeat and Until" condition) .
but my doubt is , will the global variable( ) value clear after every event call or it stores Previous value for further increment operation .

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

    It depends on how you code and declare the codeunit. It's hard to tell without actually looking at your code.

  • Manikanta_501 Profile Picture
    245 on at

    Below is standard code in 5763(Whse.-Post Shipment) Code unit in Business Central

    Counter.PNG

    and I wrote Event.

    Counter.PNG

    here CounterSourceDocTotal is global variable in my Custom Code unit.

    in my custom code I need CounterSourceDocTotal Variable value from standard code unit "5763(Whse.-Post Shipment)" ,but there is no event with this variable as parameter, So I wrote this code for getting value of CounterSourceDocTotal value by defining CounterSourceDocTotal as global variable in my custom code unit.

  • Teddy Herryanto (That NAV Guy) Profile Picture
    14,300 Super User 2026 Season 1 on at

    Don't think your global variable will work because your global variable only exists in the subscriber codeunit.

    Not sure if this will work, but there is a Single Instance property in the codeunit. I have done in NAV, but never in BC inside event subscriber. You can try testing it.

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

November Spotlight Star - Khushbu Rajvi

Congratulations to a top community star!

Forum Structure Changes Coming on 11/8!

In our never-ending quest to help the Dynamics 365 Community members get answers faster …

Dynamics 365 Community Platform update – Oct 28

Welcome to the next edition of the Community Platform Update. This is a status …

Leaderboard > Business Central

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans