web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

No record found.

News and Announcements icon
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 322
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
 
 
؟
 
 
 
 
  • KasparsSemjonovs Profile Picture
    4,851 Super User 2026 Season 1 on at
    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.
  • Suggested answer
    Yi Yong Profile Picture
    2,746 Super User 2026 Season 1 on at
    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.

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

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Women in Power Builds Momentum

Expanding mentorship, skilling, and AI innovation

Congratulations to the July Top 10 Community Leaders

These are the community rock stars!

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

#1
OussamaSabbouh Profile Picture

OussamaSabbouh 711 Super User 2026 Season 2

#2
Teagen Boll Profile Picture

Teagen Boll 377 Super User 2026 Season 2

#3
AndrewThomas81 Profile Picture

AndrewThomas81 367 Super User 2026 Season 2

Last 30 days Overall leaderboard

Featured topics

Microsoft Training Manuals

Product updates

Dynamics 365 release plans