Skip to main content

Notifications

Community site session details

Community site session details

Session Id :
Small and medium business | Business Central, N...
Suggested answer

I Need Insert (Dimension Value)

(1) ShareShare
ReportReport
Posted on by 242
Hello, I need help solving a problem I have
 
The idea I am working on is that I have data in a table in a database in SQL Server
 
And I enter this data into the (General Journals) screen. There is a field called (Employee Code) and this is specific to the Dimension Value List :
 
Table General Journals Screen: Gen. Journal Line (81)
Table Dimension Value List Screen: Dimension Value (349)
 
 
 
 
 
 
 
How do I enter the value (Employee Code) in the Dimension Value (349) table while entering data in the table (Gen. Journal Line (81)) correctly and it appears in the General Journals Screen as shown in the picture?
 
 
 
===============================================================================================
 
A question is, I want to enter the value (Employee Code) using this code. This is my code :
 
   procedure ReadDataFrom_Data_Menaitech_PAYROLL(Serial_No: Integer)
    var
        SqlConnection: DotNet SqlConnection;
        SqlCommand: DotNet SqlCommand;
        SqlDataReader: DotNet SqlDataReader;
        ConnectionString: Text;
        GenJournalLine: Record "Gen. Journal Line";
        NoSeriesMgt: Codeunit "NoSeriesManagement";
        NextDocNo: Code[20];
        GenJournalBatch: Record "Gen. Journal Batch";
        GenJnlPostBatch: Codeunit "Gen. Jnl.-Post Batch";
        Counter_Line: Integer;
        ValueNumber: Integer;
        SQLMonth: Text;
        SQLYear: Text;
        DimValue: Record "Dimension Value";
        DimCode: Code[20];
        DimValueCode: Code[40];
    begin
        Counter_Line := 1;
        ValueNumber := 0;
        ConnectionString := 'Server=DYNAMIC;Database=M_W_Menaitech;User Id=sa;Password=sapass@123;';
        SqlConnection := SqlConnection.SqlConnection(ConnectionString.Trim());
        SqlConnection.Open();
        SqlCommand := SqlCommand.SqlCommand('SELECT * FROM Data_From_Menaitech WHERE Post_On_Business_Central = 0 AND Serial_No = ' + Format(Serial_No) + ' ORDER BY Serial_No ASC', SqlConnection);
        SqlDataReader := SqlCommand.ExecuteReader();
        if GenJournalBatch.Get('GENERAL', 'PAYROLL' + Format(Serial_No)) then begin
            while SqlDataReader.Read() do begin
                if (ValueNumber <> SqlDataReader.GetInt32(15)) then begin
                    ValueNumber := SqlDataReader.GetInt32(15);
                    NextDocNo := NoSeriesMgt.GetNextNo(GenJournalBatch."No. Series", Today(), true);
                end;
                SQLMonth := SqlDataReader.GetString(0).Trim();
                SQLYear := SqlDataReader.GetString(1).Trim();
                GenJournalLine.Init();
                GenJournalLine."Line No." := Counter_Line;
                GenJournalLine."Journal Template Name" := 'GENERAL';
                GenJournalLine."Journal Batch Name" := 'PAYROLL' + Format(Serial_No);
                GenJournalLine."Posting Date" := Today();
                GenJournalLine."Document Type" := GenJournalLine."Document Type"::Payment;
                GenJournalLine."Document No." := NextDocNo;
                GenJournalLine."Account Type" := GenJournalLine."Account Type"::"Bank Account";
                GenJournalLine."Account No." := SqlDataReader.GetString(6).Trim();
                GenJournalLine.Amount := SqlDataReader.GetDecimal(8);
                if SqlDataReader.GetDecimal(8) > 0 then begin
                    GenJournalLine."Credit Amount" := SqlDataReader.GetDecimal(8);
                end else begin
                    GenJournalLine."Debit Amount" := SqlDataReader.GetDecimal(8);
                end;
                GenJournalLine.Description := SqlDataReader.GetString(10).Trim();
                GenJournalLine."Currency Code" := SqlDataReader.GetString(13).Trim();
 
 
 
        // insert Dimension Value ******************************************************************************************************
                DimValueCode := '104';
                DimCode := 'EMPLOYEE';
                if DimValue.Get(DimCode, DimValueCode) then begin
                    Message('Dimension Value %1 for Dimension %2 is valid', DimValueCode, DimCode);
             
                    Message('Validating shortcut dimension code: %1', DimValueCode);
            
                    GenJournalLine.ValidateShortcutDimCode(1, DimValueCode);
       
                    Message('Shortcut dimension code validated successfully.');
                end else begin
                    Error('Dimension Value %1 for Dimension %2 is not valid', DimValueCode, DimCode);
                end;
             //*****************************************************************************************************************************
 
 

                GenJournalLine.Insert();
                Counter_Line += 1;
            end;
            SqlDataReader.Close();
            Save_Month_AND_Year_ON_Payroll_Integration_Table(SQLMonth.Trim(), SQLYear.Trim(), Serial_No, Serial_No);
        end else begin
            Error('General Journal Batch (PAYROLL' + Format(Serial_No) + ') Not Found.');
        end;
        SqlDataReader.Close();
        SqlConnection.Close();
    end;
 
When executing the previous code, it gives me the following messages:
 
 
then
 
 
then
 
 
ØŸ
 
 
 
 
  • Suggested answer
    Yi Yong Profile Picture
    2,097 Super User 2025 Season 1 on at
    I Need Insert (Dimension Value) during Insert (General Journals Line)
    Hello,
     
    What is the shortcut dimension for 'Employee Code'?
     
     
    You can try replacing the number '1' with the shortcut dimension number of the Employee Code based on General Ledger Setup page.
  • KasparsSemjonovs Profile Picture
    4,270 Super User 2025 Season 1 on at
    I Need Insert (Dimension Value) during Insert (General Journals Line)
    To add the dimension value to the line, you don't need to insert it in table 349. 
    Table 349 just contains a list of available dimension values. This should be updated before creating lines, in case you need new values there. 

    Is the Employee dimension one of the 2 global ones? then it should be possible to enter the value directly to the Shortcut Dimension1 or 2 Value. If it is not a global dimension, then its a bit harder... need to wait for some developer to give more detailed pointers.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Jainam Kothari – Community Spotlight

We are honored to recognize Jainam Kothari as our June 2025 Community…

Congratulations to the May Top 10 Community Leaders!

These are the community rock stars!

Announcing the Engage with the Community forum!

This forum is your space to connect, share, and grow!

Leaderboard > Small and medium business | Business Central, NAV, RMS

#1
Sohail Ahmed Profile Picture

Sohail Ahmed 1,452

#2
YUN ZHU Profile Picture

YUN ZHU 1,313 Super User 2025 Season 1

#3
Gerardo Rentería García Profile Picture

Gerardo Rentería Ga... 1,083 Most Valuable Professional

Featured topics

Product updates

Dynamics 365 release plans