You must add the appropriate Insight code changes to the codeunit design. Carefully editing codeunit 80 can preserve any changes that may 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\60\Application Server\ScribeModifications\W1.6.02.32012.
To edit the codeunit, use the .txt file that matches your version of 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
Window.UPDATE(1,STRSUBSTNO(Text007,"Document
type","No.",SalesInvHeader."No."));
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 |
Name | DataType | Subtype | Length |
---|---|---|---|
CustLedgEntry | Record | Cust. Ledger Entry |
After:
SalesInvHeader.INSERT;
Add:
// Trigger ScribePublisher
RecRef.GETTABLE(SalesInvHeader);
ScribePublisher.PublishInsertion(RecRef);
After:
IF "Bal. Account No." <> '' THEN BEGIN:
Replace:
Window.UPDATE(5,1);
IF NOT IsOnlinePayment(SalesHeader) THEN
PostBalancing(TempJnlLineDim,0)
With:
//*****SCRIBE BEGINS*****
//Hide GUI window in NAS
IF GUIALLOWED THEN
Window.UPDATE(5,1);
//*****SCRIBE ENDS*****
CustLedgEntry.FINDLAST;
GenJnlLine.INIT;
GenJnlLine."Posting Date" := "Posting Date";
GenJnlLine."Document Date" := "Document Date";
GenJnlLine.Description := "Posting Description";
GenJnlLine."Shortcut Dimension 1 CodeLeft" := "Shortcut
Dimension 1 CodeLeft";
GenJnlLine."Shortcut Dimension 2 CodeLeft" := "Shortcut
Dimension 2 CodeLeft";
GenJnlLine."Reason CodeLeft" := "Reason CodeLeft";
GenJnlLine."Account Type" := GenJnlLine."Account
Type"::Customer;
GenJnlLine."Account No." := "Bill-to Customer
No.";
IF "Document Type" = "Document Type"::"Credit
Memo" THEN
GenJnlLine."Document Type"
:= GenJnlLine."Document Type"::Refund
ELSE
GenJnlLine."Document Type"
:= GenJnlLine."Document Type"::Payment;
GenJnlLine."Document No." := GenJnlLineDocNo;
GenJnlLine."External Document No." := GenJnlLineExtDocNo;
IF "Bal. Account Type" = "Bal. Account Type"::"Bank
Account" THEN
GenJnlLine."Bal. Account
Type" := GenJnlLine."Bal. Account Type"::"Bank Account";
GenJnlLine."Bal. Account No." := "Bal. Account
No.";
GenJnlLine."Currency CodeLeft" := "Currency CodeLeft";
GenJnlLine.Amount :=
TotalSalesLine."Amount
Including VAT" + CustLedgEntry."Remaining Pmt. Disc. Possible";
GenJnlLine."Source Currency CodeLeft" := "Currency
CodeLeft";
GenJnlLine."Source Currency Amount" := GenJnlLine.Amount;
GenJnlLine.Correction := Correction;
CustLedgEntry.CALCFIELDS(Amount);
IF CustLedgEntry.Amount = 0 THEN
GenJnlLine."Amount (LCY)"
:= TotalSalesLineLCY."Amount Including VAT"
ELSE
GenJnlLine."Amount (LCY)"
:=
TotalSalesLineLCY."Amount
Including VAT" +
ROUND(
CustLedgEntry."Remaining
Pmt. Disc. Possible" /
CustLedgEntry."Adjusted
Currency Factor");
IF SalesHeader."Currency CodeLeft" = '' THEN
GenJnlLine."Currency Factor"
:= 1
ELSE
GenJnlLine."Currency Factor"
:= SalesHeader."Currency Factor";
GenJnlLine."Applies-to Doc. Type" := GenJnlLineDocType;
GenJnlLine."Applies-to Doc. No." := GenJnlLineDocNo;
GenJnlLine."Source Type" := GenJnlLine."Source
Type"::Customer;
GenJnlLine."Source No." := "Bill-to Customer
No.";
GenJnlLine."Source CodeLeft" := SrcCode;
GenJnlLine."Posting No. Series" := "Posting
No. Series";
GenJnlLine."IC Partner CodeLeft" := "Sell-to IC
Partner CodeLeft";
GenJnlLine."Allow Zero-Amount Posting" := TRUE;
GenJnlPostLine.RunWithCheck(GenJnlLine,TempJnlLineDim);
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 2009 R2