CODEUNIT.RUN #3

All good things come in threes, as they say. So here is 3.

Codeunit 50000:
OnRun()
ShipMethod.INIT;
ShipMethod.INSERT;
ShipMethod.INSERT; // This duplicate statement has been put here intentionally

Codeunit 50001:
OnRun()
IF CODEUNIT.RUN(50000) THEN
  MESSAGE(‘OK’)
ELSE
  MESSAGE(‘LASTERRORTEXT: %1’, GETLASTERRORTEXT);

First “from the bare head”, but test it in NAV! Both in classic and RTC. For the latter:

  • easiest: run codeunit 50001 from NAV 2013 DE
  • on NAV 2009: you have to create a page with an action that executes codeunit 50001

Note

Variable ShipMethod in codeunit 50000 is linked to the Shipment Method table (10).

One Comment

  1. Both Yes to your questions. Just give it a try yourself.

    This is what I did:

    On TAB1":

    Description – OnValidate()

    ERROR('ERROR in OnValidate of Description field')

    On COD50000:

    OnRun()

    ShipMethod.INIT;

    ShipMethod.INSERT;

    ShipMethod.VALIDATE(Description,'Test');

    ShipMethod.MODIFY;

    Result:

    Microsoft Dynamics NAV

    —————————

    LASTERRORTEXT: ERROR in OnValidate of Description field

    —————————

    And regarding your remark "Love this new way of working": this has always been possible. It's not new. 😎

Leave a Reply to Adminflux Cancel reply

Your email address will not be published. Required fields are marked *