Insight codeunit modifications cause the Window variable to be invoked only when the GUI is allowed to prevent issues when running Insight integrations. Additional modifications publish the insertion of Sales objects.
Add the appropriate Insight code changes to the codeunit design. Carefully editing codeunit 80 can preserve any changes that have already been made to it.
The file COD80.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 Microsoft Dynamics NAV. TIBCO suggests that you review COD80.txt before editing codeunit 80.
Warning: When running the PostSalesOrder custom action which wraps Codeunit 80 Sales-Post, you may get an error message saying that you cannot use C/AL variables of type DIALOG when running the Application Server. This error is caused by the global variable Window used in OnRun trigger.
To correct the Window variable error
Note: Dynamics NAV C/AL code requires BEGIN and END keywords encapsulating compound statements. Where the “IF GUIALLOWED THEN:” statement is added, if there are multiple lines of C/AL Code invoking the Window variable, then the BEGIN and END keywords must be used to encapsulate all of lines of code.
IF GUIALLOWED THEN
For example, for the following statement:
Window.UPDATE(1,STRSUBSTNO(Text007,"Document
type","No.",SalesInvHeader."No."));
Add IF GUIALLOWED THEN:
//*****Scribe Begins*****
//Hide GUI window in NAS
IF GUIALLOWED THEN
Window.UPDATE(1,STRSUBSTNO(Text007,"Document type","No.",SalesInvHeader."No."));
//*****Scribe Ends*****
This eliminates the error message when the NAS runs codeunit 80.
After you correct the Window variable error, make the remaining required edits to codeunit 80.
To edit codeunit 80
Name | DataType | Subtype | Length |
---|---|---|---|
ScribePublisher | Codeunit | Scribe Publisher | |
RecRef | RecordRef |
Before:
OnAfterPostSalesDoc(
Rec,GenJnlPostLine,SalesShptHeader."No.",ReturnRcptHeader."No.",SalesInvHeader."No.",SalesCrMemoHeader."No.");
Add:
IF NOT SalesHeader.IsCreditDocType THEN BEGIN
//*****Scribe Begins*****
// Trigger ScribePublisher
RecRef.GETTABLE(SalesInvHeader);
ScribePublisher.PublishInsertion(RecRef);
//*****Scribe Ends*****
END;
See also
Editing the codeunits — Dynamics NAV 2018