O'Reilly logo

Extending Microsoft Dynamics NAV 2016 Cookbook by Alexander Drogin

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Running tasks in background sessions

When you execute long-running tasks, such as generating a large report or posting many documents in one batch, this blocks the user interface, forcing the user to wait until the task completes. Such extensive tasks can be run as background sessions, while the UI remains responsive.

How to do it...

This recipe shows how to run a batch job in a background session. The code in the recipe starts a session that posts sales and purchase invoices:

  1. Create a codeunit 50019 Post Invoices.
  2. In the OnRun trigger, declare the following local variables:

    Name

    DataType

    Subtype

    SalesHeader

    Record

    Sales Header

    PurchaseHeader

    Record

    Purchase Header

    SalesPost

    Codeunit

    Sales-Post

    PurchPost

    Codeunit

    Purch.-Post ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required