I am looking up the Global Dim 1 (Project) from the Sales header, the code added works except the Project Code is not added except by performing the following steps:
Check if the Project Code has been added to the Document Dimension table, lookup the Project Code again, check the Document Dimensions again and when exit, the Project Code is inserted.
Here is the code:
Shortcut Dimension 1 Code - OnValidate()
ValidateShortcutDimCode(1,“Shortcut Dimension 1 Code”);
///x >>
IF “Shortcut Dimension 1 Code” <> xRec.“Shortcut Dimension 1 Code” THEN
IF “Shortcut Dimension 1 Code” <> ‘’ THEN BEGIN
GLSetup.GET();
DimVal.GET(GLSetup.“Shortcut Dimension 1 Code”,“Shortcut Dimension 1 Code”);
VALIDATE(“Sell-to Customer No.” , DimVal.“Customer No.”);
DocDim3.SETRANGE(“Table ID” , DATABASE::“Sales Header”);
DocDim3.SETRANGE(“Document Type” , “Document Type”::Order);
DocDim3.SETRANGE(“Document No.” , “No.”);
DocDim3.SETRANGE(“Line No.” , 0);
DocDim3.SETRANGE(“Dimension Code” , GLSetup.“Shortcut Dimension 3 Code”);
DocDim3.SETFILTER(“Dimension Value Code” , ‘%1’ , DimVal.“Shortcut Dimension Code 3”);
IF NOT DocDim3.FINDFIRST THEN BEGIN
DocDim3.INIT;
DocDim3.“Table ID” := DATABASE::“Sales Header”;
DocDim3.“Document Type” := “Document Type”::Order;
DocDim3.“Document No.” := “No.”;
DocDim3.“Line No.” := 0;
DocDim3.“Dimension Code” := GLSetup.“Shortcut Dimension 3 Code”;
DocDim3.“Dimension Value Code” := DimVal.“Shortcut Dimension Code 3”;
DocDim3.INSERT;
END;
END;
(There are 2 new fields in the Dimension Value table for the Customer No. and Shortcut Dimension 3).
NAV 2009 R2 Classic