Here is the code I have used, in the G/L Entry table
Global Var:LedgerEntryDim2 = Ledger Entry Dimension
Global Dimension 2 Code - OnValidate()
///================GL Entry Dim update=====================
CLEAR(LedgerEntryDim2);
LedgerEntryDim2.SETFILTER(“Table ID”, ‘%1’, DATABASE::“G/L Entry”);
LedgerEntryDim2.SETFILTER(“Entry No.”, ‘%1’, “Entry No.”);
LedgerEntryDim2.SETFILTER(“Dimension Code”,’%1’,‘PROJECT’);
///MODIFY EXISTING RECORD IN TABLE 355
IF LedgerEntryDim2.FIND(’-’) THEN BEGIN
LedgerEntryDim2.“Dimension Value Code” := “Global Dimension 2 Code”;
LedgerEntryDim2.MODIFY;
END ELSE BEGIN
///INSERT RECORD IN TABLE 355 IF NO PREVIOUS ENTRY FOUND
LedgerEntryDim2.“Table ID” := DATABASE::“G/L Entry”;
LedgerEntryDim2.“Entry No.” := “Entry No.”;
LedgerEntryDim2.“Dimension Code” := ‘PROJECT’;
LedgerEntryDim2.“Dimension Value Code” := “Global Dimension 2 Code”;
LedgerEntryDim2.INSERT;
END;
I have a form that shows the Dimension as the only editable field, I also have a new field to show the original value:
here is the code from the form:
Global Dimension 2 Code - OnValidate()
IF “Global Dimension 2 Code” <> xRec.“Global Dimension 2 Code” THEN BEGIN
IF “Original Project Code” = ‘’ THEN
“Original Project Code” := xRec.“Global Dimension 2 Code”;
CLEAR(LedgerEntryDim2); ///
LedgerEntryDim2.SETFILTER(“Table ID”, ‘%1’, DATABASE::“G/L Entry”);
LedgerEntryDim2.SETFILTER(“Entry No.”, ‘%1’, “Entry No.”);
LedgerEntryDim2.SETFILTER(“Dimension Code”,’%1’,‘PROJECT’);
///MODIFY EXISTING RECORD IN TABLE 355
IF LedgerEntryDim2.FIND(’-’) THEN BEGIN
LedgerEntryDim2.“Dimension Value Code” := “Global Dimension 2 Code”;
LedgerEntryDim2.MODIFY;
END ELSE BEGIN
///INSERT RECORD IN TABLE 355 IF NO PREVIOUS ENTRY FOUND
LedgerEntryDim2.“Table ID” := DATABASE::“G/L Entry”;
LedgerEntryDim2.“Entry No.” := “Entry No.”;
LedgerEntryDim2.“Dimension Code” := ‘PROJECT’;
LedgerEntryDim2.“Dimension Value Code” := “Global Dimension 2 Code”;
LedgerEntryDim2.INSERT;
END;
END;
It is possible to change related tables but is a lot more coding, if the end result is G/L Reports then this will be all that is needed.
Hope this helps,
Colin