Editing codeunit 414 — Dynamics NAV 2018

Insight codeunit modifications allow publishing of modifications of Sales headers to Insight.

Add the appropriate Insight code changes to the codeunit design. Carefully editing codeunit 414 can preserve any changes that have already been made to it.

The file COD414.txt resides in the NAS working directory subfolder that holds the Dynamics NAV localization, database version, and build, for example: ..\Microsoft Dynamics NAV\110\Service\Add-Ins\Scribe\W1.11.0.19394.

To edit the codeunit, use the .txt file that matches your version of Dynamics NAV. TIBCO suggests that you review COD414.txt before editing codeunit 414.

To edit codeunit 414

  1. Open the Microsoft Dynamics NAV Development Environment.
  2. Click Tools > Object Designer. The Object Designer appears.
  3. Click Codeunit (Codeunit Icon).
  1. From the list of codeunits, select codeunit 414, Release Sales Document.
  2. Click Design to open the C/AL Editor.
  3. Click anywhere in the LinesWereModified section of the open codeunit.
  4. On Microsoft Dynamics NAV 2018 Development Environment View menu, click C/AL Locals.
  5. On the Variables tab, add the following local variables:
    NameDataTypeSubtypeLength
    ScribePublisher Codeunit Scribe Publisher 
    RecRefRecordRef  
    xRecRefRecordRef  
  6. Close the C/AL Locals window to return to the C/AL Editor.
  7. In the LinesWereModified section:

    After:

    IF Status = Status::Released THEN
       EXIT;

    Add:

    // ***** SCRIBE BEGINS *****
    // Get the RecordRef of the original record
    xRecRef.GETTABLE(SalesHeader);
    // ***** SCRIBE ENDS *****

  8. At the end of the LinesWereModified section:

    Before:

    OnAfterReleaseSalesDoc(SalesHeader,PreviewMode,LinesWereModified);

    Add:

    // ***** SCRIBE BEGINS *****
    // Trigger the Scribe Publisher
    RecRef.GETTABLE(SalesHeader);
    ScribePublisher.PublishModification(RecRef,xRecRef);
    // ***** SCRIBE ENDS *****

  9. In the C/AL Editor, click in the Reopen section of the codeunit, then open the C/AL Locals window.
  10. Click the Variables tab, then add the following variables:
    NameDataTypeSubtypeLength
    ScribePublisher Codeunit Scribe Publisher 
    RecRefRecordRef  
    xRecRefRecordRef  
  11. Close the C/AL Locals window to return to the C/AL Editor.
  12. In the Reopen section:

    After: 

    IF Status = Status::Open THEN EXIT;

    Add:

    // ***** SCRIBE BEGINS *****
    // Get RecordRef of the original record
    xRecRef.GETTABLE(SalesHeader);
    // ***** SCRIBE ENDS *****

    After: 

    WhseSalesRelease.Reopen(SalesHeader);

    Add:

    // ***** SCRIBE BEGINS *****
    RecRef.GETTABLE(SalesHeader);
    ScribePublisher.PublishModification(RecRef,xRecRef);
    // ***** SCRIBE ENDS *****

  13. When you are done, save the codeunit and make sure that it compiles without errors.

    Make a note of the codeunit's new revision level.

    Note: In the Object Designer, in the Version List column, edit the Release Sales Document codeunit's version to reflect the new revision level.

See also

Editing the codeunits — Dynamics NAV 2018

Next step